Skip to content

Commit d87d024

Browse files
Al12rserri120
authored andcommitted
Fix GOG game files query:
- Depots were not filtered by BuildId, but only by base product id, so depots for all builds were being included. - Ensured that the DLC depots join with LocatorIds would also check the Loadout matching - Tried to make what is happening clearer
1 parent b3f2973 commit d87d024

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/NexusMods.Games.FileHashes/FileHashesQueries.sql

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,31 @@ SELECT files.Loadout, files.FileId PathId FROM
5454
-- gets all the paths and hashes of game files for gog loadouts
5555
CREATE OR REPLACE MACRO file_hashes.gog_loadout_files(db) AS TABLE
5656
WITH
57+
-- GOG locatorIds can contain a mix of BuildIds and DLC ProductIds
5758
locatorIds AS (SELECT Loadout, LocatorId::UBIGINT LocatorId
5859
FROM file_hashes.loadout_locatorids(db) locators
5960
WHERE locators.Store = 'GOG'),
60-
builds AS (SELECT Loadout, BuildId, ProductId BaseProductId, unnest(build.Depots) DepotId
61+
builds AS (SELECT Loadout, BuildId, ProductId BuildProductId, unnest(build.Depots) DepotId
6162
FROM MDB_GOGBUILD(DBName=>"hashes") build
6263
INNER JOIN locatorIds ON build.BuildId = locatorIds.LocatorId),
63-
validDepots AS (SELECT Id, ProductId, Manifest
64-
FROM MDB_GOGDEPOT(DBName=>"hashes")
64+
validDepots AS (SELECT Id, ProductId, Manifest ManifestId
65+
FROM MDB_GOGDEPOT(DBName=>"hashes")
6566
WHERE Languages == [] OR 'en-US' in Languages),
66-
manifests AS (SELECT builds.Loadout, validDepots.Manifest
67-
FROM validDepots
68-
INNER JOIN builds ON validDepots.ProductId = builds.BaseProductId
67+
buildDepots AS (SELECT builds.Loadout, builds.DepotId, validDepots.ProductId DepotProductId, builds.BuildProductId, validDepots.ManifestId
68+
FROM builds
69+
JOIN validDepots on validDepots.Id = builds.DepotId),
70+
manifests AS (-- Depots for the base game product
71+
SELECT buildDepots.Loadout, buildDepots.ManifestId
72+
FROM buildDepots
73+
WHERE buildDepots.DepotProductId = buildDepots.BuildProductId
6974
UNION
70-
SELECT locatorIds.Loadout, validDepots.Manifest
71-
FROM validDepots
72-
INNER JOIN locatorIds ON validDepots.ProductId = LocatorIds.LocatorId),
75+
-- Depots for DLC products
76+
SELECT buildDepots.Loadout, buildDepots.ManifestId
77+
FROM buildDepots
78+
JOIN locatorIds dlcProducts ON dlcProducts.Loadout = buildDepots.Loadout AND buildDepots.DepotProductId = dlcProducts.LocatorId),
7379
files AS (SELECT Loadout, unnest(manifest.Files) File
7480
FROM manifests
75-
LEFT JOIN MDB_GOGMANIFEST(DBName=>"hashes") manifest ON manifests.Manifest = manifest.Id)
81+
LEFT JOIN MDB_GOGMANIFEST(DBName=>"hashes") manifest ON manifests.ManifestId = manifest.Id)
7682
SELECT files.Loadout, files.File PathId FROM files;
7783

7884
-- gets all the paths and hashes for game files in loadouts

0 commit comments

Comments
 (0)