mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Added redownload option to repair.
This commit is contained in:
parent
e0c53633b4
commit
f3f26d4da3
6
main.cpp
6
main.cpp
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
("list", bpo::value<bool>(&config.bList)->zero_tokens()->default_value(false), "List games")
|
||||
("list-details", bpo::value<bool>(&config.bListDetails)->zero_tokens()->default_value(false), "List games with detailed info")
|
||||
("download", bpo::value<bool>(&config.bDownload)->zero_tokens()->default_value(false), "Download")
|
||||
("repair", bpo::value<bool>(&config.bRepair)->zero_tokens()->default_value(false), "Repair downloaded files")
|
||||
("repair", bpo::value<bool>(&config.bRepair)->zero_tokens()->default_value(false), "Repair downloaded files\nUse --repair --download to redownload files when filesizes don't match (possibly different version). This will delete the old file")
|
||||
("game", bpo::value<std::string>(&config.sGameRegex)->default_value(""), "Set regular expression filter\nfor download/list/repair (Perl syntax)\nAliases: \"all\", \"free\"")
|
||||
("directory", bpo::value<std::string>(&config.sDirectory)->default_value(""), "Set download directory")
|
||||
#ifndef ENVIRONMENT32
|
||||
@ -189,10 +189,10 @@ int main(int argc, char *argv[])
|
||||
return result;
|
||||
else if (config.bUpdateCheck) // Update check has priority over download and list
|
||||
downloader.updateCheck();
|
||||
else if (config.bDownload) // Download games
|
||||
downloader.download();
|
||||
else if (config.bRepair) // Repair file
|
||||
downloader.repair();
|
||||
else if (config.bDownload) // Download games
|
||||
downloader.download();
|
||||
else if (config.bListDetails || config.bList) // Detailed list of games/extras
|
||||
downloader.listGames();
|
||||
else
|
||||
|
@ -657,6 +657,26 @@ int Downloader::repairFile(std::string url, std::string filepath, std::string xm
|
||||
{
|
||||
std::cout << "Filesizes don't match" << std::endl
|
||||
<< "Incomplete download or different version" << std::endl;
|
||||
if (this->config.bDownload)
|
||||
{
|
||||
fclose(outfile);
|
||||
std::cout << "Redownloading file" << std::endl;
|
||||
boost::filesystem::path path = filepath;
|
||||
if (!boost::filesystem::remove(path))
|
||||
{
|
||||
std::cout << "Failed to delete " << path << std::endl;
|
||||
res = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CURLcode result = this->downloadFile(url, filepath);
|
||||
std::cout << std::endl;
|
||||
if (result == CURLE_OK)
|
||||
res = 1;
|
||||
else
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user