diff --git a/include/config.h b/include/config.h index 3803b8b..3f269d4 100644 --- a/include/config.h +++ b/include/config.h @@ -55,6 +55,7 @@ struct DownloadConfig bool bIgnoreDLCCount; bool bDuplicateHandler; bool bGalaxyDependencies; + bool bGalaxyDeleteOrphans; }; struct gameSpecificConfig diff --git a/main.cpp b/main.cpp index 82c8c00..0be55b0 100644 --- a/main.cpp +++ b/main.cpp @@ -271,6 +271,7 @@ int main(int argc, char *argv[]) ("galaxy-no-dependencies", bpo::value(&bNoGalaxyDependencies)->zero_tokens()->default_value(false), "Don't download dependencies during --galaxy-install") ("subdir-galaxy-install", bpo::value(&Globals::globalConfig.dirConf.sGalaxyInstallSubdir)->default_value("%install_dir%"), galaxy_install_subdir_text.c_str()) ("galaxy-cdn-priority", bpo::value(&sGalaxyCDN)->default_value("edgecast,highwinds,gog_cdn"), galaxy_cdn_priority_text.c_str()) + ("galaxy-delete-orphans", bpo::value(&Globals::globalConfig.dlConf.bGalaxyDeleteOrphans)->zero_tokens()->default_value(false), "Delete orphaned files during --galaxy-install") ; options_cli_all.add(options_cli_no_cfg).add(options_cli_cfg).add(options_cli_experimental); diff --git a/src/downloader.cpp b/src/downloader.cpp index ba4bc4b..5d3c964 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -3425,7 +3425,18 @@ void Downloader::galaxyInstallGameById(const std::string& product_id, int build_ std::vector orphans = this->galaxyGetOrphanedFiles(items, install_path); std::cout << "\t" << orphans.size() << " orphaned files" << std::endl; for (unsigned int i = 0; i < orphans.size(); ++i) - std::cout << "\t" << orphans[i] << std::endl; + { + if (Globals::globalConfig.dlConf.bGalaxyDeleteOrphans) + { + std::string filepath = orphans[i]; + std::cout << "Deleting " << filepath << std::endl; + if (boost::filesystem::exists(filepath)) + if (!boost::filesystem::remove(filepath)) + std::cerr << "Failed to delete " << filepath << std::endl; + } + else + std::cout << "\t" << orphans[i] << std::endl; + } } void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Config conf, const unsigned int& tid)