Exit with non-zero status when at least one --download-file fails

This commit is contained in:
James Le Cuirot 2016-09-23 22:16:13 +01:00
parent 4ee63f7e87
commit d8b8d6da96
No known key found for this signature in database
GPG Key ID: 21C632129C6D7DE4
3 changed files with 10 additions and 6 deletions

View File

@ -72,7 +72,7 @@ class Downloader
void checkOrphans();
void checkStatus();
void updateCache();
void downloadFileWithId(const std::string& fileid_string, const std::string& output_filepath);
int downloadFileWithId(const std::string& fileid_string, const std::string& output_filepath);
void showWishlist();
CURL* curlhandle;
Timer timer;

View File

@ -550,6 +550,9 @@ int main(int argc, char *argv[])
return 1;
}
}
int res = 0;
if (config.bShowWishlist)
downloader.showWishlist();
else if (config.bUpdateCache)
@ -560,7 +563,7 @@ int main(int argc, char *argv[])
{
for (std::vector<std::string>::iterator it = vFileIdStrings.begin(); it != vFileIdStrings.end(); it++)
{
downloader.downloadFileWithId(*it, config.sOutputFilename);
res |= downloader.downloadFileWithId(*it, config.sOutputFilename) ? 1 : 0;
}
}
else if (config.bRepair) // Repair file
@ -587,5 +590,5 @@ int main(int argc, char *argv[])
if (!config.sOrphanRegex.empty() && config.bDownload)
downloader.checkOrphans();
return 0;
return res;
}

View File

@ -2790,8 +2790,9 @@ void Downloader::saveChangelog(const std::string& changelog, const std::string&
return;
}
void Downloader::downloadFileWithId(const std::string& fileid_string, const std::string& output_filepath)
int Downloader::downloadFileWithId(const std::string& fileid_string, const std::string& output_filepath)
{
int res = 1;
size_t pos = fileid_string.find("/");
if (pos == std::string::npos)
{
@ -2825,7 +2826,7 @@ void Downloader::downloadFileWithId(const std::string& fileid_string, const std:
else
filepath = output_filepath;
std::cout << "Downloading: " << filepath << std::endl;
this->downloadFile(url, filepath, std::string(), gamename);
res = this->downloadFile(url, filepath, std::string(), gamename);
std::cout << std::endl;
}
else
@ -2835,7 +2836,7 @@ void Downloader::downloadFileWithId(const std::string& fileid_string, const std:
}
}
return;
return res;
}
void Downloader::showWishlist()