From 3dccc82a31197469fedf56de49686fce1e7add1e Mon Sep 17 00:00:00 2001 From: torkus <48790775+torkus@users.noreply.github.com> Date: Thu, 21 Dec 2023 18:52:53 +1030 Subject: [PATCH] Bug fixes (#419) * toc, no longer parse x-tukui values * specs, catalogue/location 'source' is now a url, not an addon/source, which seems completely wrong and is only passing because 'unknown?' is a 'string' * bug, wrath toc files were being ignored * tests, removed tukui source precedence * toc, adds precedence test for github * toc, adds support for detecting github url via 'x-website' * moves Dockerfiles into CircleCI dir --- CHANGELOG.md | 8 +++ Dockerfile => CircleCI/Dockerfile | 0 .../Dockerfile.buster | 0 TODO.md | 15 +++-- src/strongbox/addon.clj | 3 +- src/strongbox/specs.clj | 3 +- src/strongbox/toc.clj | 25 +++++--- .../fixtures/everyaddon--1-2-3--multi-toc.zip | Bin 2496 -> 2860 bytes test/strongbox/toc_test.clj | 54 +++++++++++++----- 9 files changed, 77 insertions(+), 31 deletions(-) rename Dockerfile => CircleCI/Dockerfile (100%) rename Dockerfile.buster => CircleCI/Dockerfile.buster (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b1a01b..412cc8de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* `x-website` Github URLs in `.toc` files are now treated as a Github source that an addon can be switched to. + - when both `x-github` and Github `x-website` sources exist, `x-github` takes priority. + ### Changed ### Fixed +* fixed bug preventing classic Wrath `.toc` from being detected and loaded. +* fixed bug in catalogue location spec where a value that should have been validating as a URL was not. +* removed `x-tukui-id` source detection in `.toc` files. Tukui no longer hosts addons so these can't be used. + - overlooked, should have been part of 7.0.0 major version. + ### Removed ## 7.1.0 - 2023-11-26 diff --git a/Dockerfile b/CircleCI/Dockerfile similarity index 100% rename from Dockerfile rename to CircleCI/Dockerfile diff --git a/Dockerfile.buster b/CircleCI/Dockerfile.buster similarity index 100% rename from Dockerfile.buster rename to CircleCI/Dockerfile.buster diff --git a/TODO.md b/TODO.md index 189c9e2e..9c0147e1 100644 --- a/TODO.md +++ b/TODO.md @@ -6,17 +6,22 @@ see CHANGELOG.md for a more formal list of changes by release ## done -## todo - -* cataclysm classic support +* move Dockerfile* files into a CircleCI folder + - done -* *.sh, consolidate these root-level bash scripts into a manage.sh +* toc, what is the usage of 'x-github'. we're expecting a url but a foo/bar seems fine as well + - check the github catalogue + - I'm seeing more usage of 'x-website' + - done -* move Dockerfile* files into a CircleCI folder +## todo +* *.sh, consolidate these root-level bash scripts into a manage.sh ## todo bucket (no particular order) +* cataclysm classic support + * nfo, replace the URL as the group-id with something random * github, catalogue, no download counts. diff --git a/src/strongbox/addon.clj b/src/strongbox/addon.clj index d8728e7b..7afd5c09 100644 --- a/src/strongbox/addon.clj +++ b/src/strongbox/addon.clj @@ -210,7 +210,8 @@ group-addons)) (defn-spec load-installed-addon (s/or :ok-toc :addon/toc, :ok-nfo :addon/nfo, :error nil?) - "reads and merges the toc data and the nfo data from a specific `addon-dir` and all those in it's group, groups them up (again) and returns the grouped mooshed data. + "reads and merges the toc data and the nfo data for a specific addon at `addon-dir` (bad name) and all those in it's group, + groups them up (again) and returns the grouped mooshed data. this was introduced much later than `load-all-installed-addons` as parallel installation and loading of addons was introduced." [addon-dir ::sp/addon-dir, game-track ::sp/game-track] (logging/with-addon {:dirname (-> addon-dir fs/base-name str)} diff --git a/src/strongbox/specs.clj b/src/strongbox/specs.clj index 433bc9fb..befe7a57 100644 --- a/src/strongbox/specs.clj +++ b/src/strongbox/specs.clj @@ -451,9 +451,10 @@ ;; catalogue locations (s/def :catalogue/name keyword?) +(s/def :catalogue/source ::url) ;; a `catalogue/location` is a description of a catalogue and where to find it, not the catalogue itself. -(s/def :catalogue/location (s/keys :req-un [:catalogue/name ::label :addon/source])) +(s/def :catalogue/location (s/keys :req-un [:catalogue/name ::label :catalogue/source])) (s/def :catalogue/location-list (s/or :ok (s/coll-of :catalogue/location) :empty ::empty-coll)) diff --git a/src/strongbox/toc.clj b/src/strongbox/toc.clj index d713347d..76754fec 100644 --- a/src/strongbox/toc.clj +++ b/src/strongbox/toc.clj @@ -54,7 +54,7 @@ "returns a list of file names as `[[game-track, filename.toc], ...]` in the given `addon-dir`. `game-track` is `nil` if it can't be guessed from the filename (and not 'retail')." [addon-dir ::sp/extant-dir] - (let [pattern (Pattern/compile "(?u)^(.+?)(?:[\\-_]{1}(Mainline|Classic|Vanilla|TBC|BCC){1})?\\.toc$") + (let [pattern (Pattern/compile "(?u)^(.+?)(?:[\\-_]{1}(Mainline|Classic|Vanilla|TBC|BCC|Wrath){1})?\\.toc$") matching-toc-pattern (fn [filename] (let [toc-bname (str (fs/base-name filename)) [toc-bname-match game-track-match] (rest (re-matches pattern toc-bname))] @@ -121,16 +121,22 @@ ;; {:source "curseforge" ;; :source-id x-curse-id}) - tukui-source (when-let [x-tukui-id (-> keyvals :x-tukui-projectid utils/to-int)] - {:source "tukui" - :source-id x-tukui-id}) + ;;tukui-source (when-let [x-tukui-id (-> keyvals :x-tukui-projectid utils/to-int)] + ;; {:source "tukui" + ;; :source-id x-tukui-id}) github-source (when-let [x-github (-> keyvals :x-github)] {:source "github" :source-id (utils/github-url-to-source-id x-github)}) - source-map-list (when-let [items (->> [wowi-source tukui-source github-source - ;;curse-source + github-website-source (when-let [x-website (-> keyvals :x-website)] + (when (and (not github-source) + (.startsWith x-website "https://github.com")) + {:source "github" + :source-id (utils/github-url-to-source-id x-website)})) + + source-map-list (when-let [items (->> [wowi-source github-source github-website-source + ;;curse-source tukui-source ] utils/items utils/nilable)] @@ -177,10 +183,11 @@ (assoc addon :dirsize dirsize) addon) - ;; prefers tukui over wowi, wowi over github. I'd like to prefer github over wowi, but github - ;; requires API calls to interact with and these are limited unless authenticated. + ;; prefers wowi over github and github over github-via-website. + ;; I'd like to prefer github over wowi, but github requires API calls to interact with and these are limited unless authenticated. addon (merge addon - github-source wowi-source tukui-source + github-website-source github-source wowi-source + ;; curse-source tukui-source ignore-flag source-map-list)] (if-not (s/valid? :addon/toc addon) diff --git a/test/fixtures/everyaddon--1-2-3--multi-toc.zip b/test/fixtures/everyaddon--1-2-3--multi-toc.zip index 779c1dafff1b6bda52cafebdb7e5f922a7f21afe..8f7fd37703112070569aa359a212c6d2c1deb038 100644 GIT binary patch delta 336 zcmX>gyhdz;1gp3RGXnz$!@((2!!_S(UEjyRz@W&;z#u=_kVTR;yeP3GV{#yiNPWgz zP4m;+F2r$dt(bc8%q)i!FH*uj-j`-SxL5VOwfvbJw)>HuY&H{`uRf~Xm@~WUe_(Ly zdG3?BZ*9{f%JT1?+NA5*Ip=Q6wZ&{=?DjH7UwqnZr#2s%9F=>N>3Rd#%tq4*47Xz9 zn=Pk^^gCYWt&w39I`#FhjM0M`C5u-)X)t=HFI?&U?}d$<;{D4jEew8bO`Xx>V^*QK z-?g)UpOJ0G_oFuRYwQDVEz6C&v{dl+Grr9ttjCyfdhH{JnyxO`Z+a#9$y^KyKu