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 checkOrphans();
void checkStatus(); void checkStatus();
void updateCache(); 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(); void showWishlist();
CURL* curlhandle; CURL* curlhandle;
Timer timer; Timer timer;

View File

@ -550,6 +550,9 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
} }
int res = 0;
if (config.bShowWishlist) if (config.bShowWishlist)
downloader.showWishlist(); downloader.showWishlist();
else if (config.bUpdateCache) 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++) 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 else if (config.bRepair) // Repair file
@ -587,5 +590,5 @@ int main(int argc, char *argv[])
if (!config.sOrphanRegex.empty() && config.bDownload) if (!config.sOrphanRegex.empty() && config.bDownload)
downloader.checkOrphans(); downloader.checkOrphans();
return 0; return res;
} }

View File

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