Galaxy: Add option to delete orphaned files

This commit is contained in:
Sude 2019-06-06 20:00:38 +03:00
parent bdf2716eaa
commit bcccec416f
3 changed files with 14 additions and 1 deletions

View File

@ -55,6 +55,7 @@ struct DownloadConfig
bool bIgnoreDLCCount; bool bIgnoreDLCCount;
bool bDuplicateHandler; bool bDuplicateHandler;
bool bGalaxyDependencies; bool bGalaxyDependencies;
bool bGalaxyDeleteOrphans;
}; };
struct gameSpecificConfig struct gameSpecificConfig

View File

@ -271,6 +271,7 @@ int main(int argc, char *argv[])
("galaxy-no-dependencies", bpo::value<bool>(&bNoGalaxyDependencies)->zero_tokens()->default_value(false), "Don't download dependencies during --galaxy-install") ("galaxy-no-dependencies", bpo::value<bool>(&bNoGalaxyDependencies)->zero_tokens()->default_value(false), "Don't download dependencies during --galaxy-install")
("subdir-galaxy-install", bpo::value<std::string>(&Globals::globalConfig.dirConf.sGalaxyInstallSubdir)->default_value("%install_dir%"), galaxy_install_subdir_text.c_str()) ("subdir-galaxy-install", bpo::value<std::string>(&Globals::globalConfig.dirConf.sGalaxyInstallSubdir)->default_value("%install_dir%"), galaxy_install_subdir_text.c_str())
("galaxy-cdn-priority", bpo::value<std::string>(&sGalaxyCDN)->default_value("edgecast,highwinds,gog_cdn"), galaxy_cdn_priority_text.c_str()) ("galaxy-cdn-priority", bpo::value<std::string>(&sGalaxyCDN)->default_value("edgecast,highwinds,gog_cdn"), galaxy_cdn_priority_text.c_str())
("galaxy-delete-orphans", bpo::value<bool>(&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); options_cli_all.add(options_cli_no_cfg).add(options_cli_cfg).add(options_cli_experimental);

View File

@ -3425,8 +3425,19 @@ void Downloader::galaxyInstallGameById(const std::string& product_id, int build_
std::vector<std::string> orphans = this->galaxyGetOrphanedFiles(items, install_path); std::vector<std::string> orphans = this->galaxyGetOrphanedFiles(items, install_path);
std::cout << "\t" << orphans.size() << " orphaned files" << std::endl; std::cout << "\t" << orphans.size() << " orphaned files" << std::endl;
for (unsigned int i = 0; i < orphans.size(); ++i) for (unsigned int i = 0; i < orphans.size(); ++i)
{
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; std::cout << "\t" << orphans[i] << std::endl;
} }
}
void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Config conf, const unsigned int& tid) void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Config conf, const unsigned int& tid)
{ {