From 8cbc62b8cda47b705efaa9ded6cb52dccf559ada Mon Sep 17 00:00:00 2001 From: Sude Date: Mon, 6 Mar 2017 06:58:11 +0200 Subject: [PATCH] Galaxy: Fix downloading DLC files Add product id from depot JSON to galaxyDepotItem struct Previously downloader failed to download DLC files because DLCs have different product id than base game Fix downloading DLC files by setting product id for each depot item --- include/galaxyapi.h | 2 +- src/downloader.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/galaxyapi.h b/include/galaxyapi.h index 5257654..50260e6 100644 --- a/include/galaxyapi.h +++ b/include/galaxyapi.h @@ -26,7 +26,6 @@ struct galaxyDepotItemChunk uintmax_t size_uncompressed; uintmax_t offset_compressed; uintmax_t offset_uncompressed; - }; struct galaxyDepotItem @@ -36,6 +35,7 @@ struct galaxyDepotItem uintmax_t totalSizeCompressed; uintmax_t totalSizeUncompressed; std::string md5; + std::string product_id; }; class galaxyAPI diff --git a/src/downloader.cpp b/src/downloader.cpp index 77cf16b..eaf6583 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -3556,11 +3556,21 @@ void Downloader::galaxyInstallGame(const std::string& product_id, int build_inde continue; std::string depotHash = json["depots"][i]["manifest"].asString(); + std::string depot_product_id = json["depots"][i]["productId"].asString(); + + if (depot_product_id.empty()) + depot_product_id = product_id; + std::vector vec = gogGalaxy->getDepotItemsVector(depotHash); + + // Set product id for items + for (auto it = vec.begin(); it != vec.end(); ++it) + it->product_id = depot_product_id; + items.insert(std::end(items), std::begin(vec), std::end(vec)); } - off_t totalSize = 0; + uintmax_t totalSize = 0; for (unsigned int i = 0; i < items.size(); ++i) { if (Globals::globalConfig.bVerbose) @@ -3716,7 +3726,7 @@ void Downloader::galaxyInstallGame(const std::string& product_id, int build_inde chunk.memory = (char *) malloc(1); chunk.size = 0; - json = gogGalaxy->getSecureLink(product_id, gogGalaxy->hashToGalaxyPath(items[i].chunks[j].md5_compressed)); + json = gogGalaxy->getSecureLink(items[i].product_id, gogGalaxy->hashToGalaxyPath(items[i].chunks[j].md5_compressed)); // Prefer edgecast urls bool bPreferEdgecast = true;