mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Galaxy: Add option to delete orphaned files
This commit is contained in:
parent
bdf2716eaa
commit
bcccec416f
@ -55,6 +55,7 @@ struct DownloadConfig
|
||||
bool bIgnoreDLCCount;
|
||||
bool bDuplicateHandler;
|
||||
bool bGalaxyDependencies;
|
||||
bool bGalaxyDeleteOrphans;
|
||||
};
|
||||
|
||||
struct gameSpecificConfig
|
||||
|
1
main.cpp
1
main.cpp
@ -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")
|
||||
("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-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);
|
||||
|
@ -3425,7 +3425,18 @@ void Downloader::galaxyInstallGameById(const std::string& product_id, int build_
|
||||
std::vector<std::string> 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user