mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
Add option to set message verbosity level
Replaced --verbose option with --verbosity to better control message verbosity
This commit is contained in:
parent
a4423b0548
commit
e5d347d5b2
@ -247,7 +247,6 @@ class Config
|
|||||||
bool bIncludeHiddenProducts;
|
bool bIncludeHiddenProducts;
|
||||||
bool bSizeOnly;
|
bool bSizeOnly;
|
||||||
|
|
||||||
bool bVerbose;
|
|
||||||
bool bUnicode; // use Unicode in console output
|
bool bUnicode; // use Unicode in console output
|
||||||
bool bColor; // use colors
|
bool bColor; // use colors
|
||||||
bool bReport;
|
bool bReport;
|
||||||
@ -322,6 +321,7 @@ class Config
|
|||||||
int iWait;
|
int iWait;
|
||||||
size_t iChunkSize;
|
size_t iChunkSize;
|
||||||
int iProgressInterval;
|
int iProgressInterval;
|
||||||
|
int iMsgLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_H__
|
#endif // CONFIG_H__
|
||||||
|
@ -14,16 +14,22 @@ const unsigned int MSGTYPE_WARNING = 1 << 1;
|
|||||||
const unsigned int MSGTYPE_ERROR = 1 << 2;
|
const unsigned int MSGTYPE_ERROR = 1 << 2;
|
||||||
const unsigned int MSGTYPE_SUCCESS = 1 << 3;
|
const unsigned int MSGTYPE_SUCCESS = 1 << 3;
|
||||||
|
|
||||||
|
const int MSGLEVEL_ALWAYS = -1;
|
||||||
|
const int MSGLEVEL_DEFAULT = 0;
|
||||||
|
const int MSGLEVEL_VERBOSE = 1;
|
||||||
|
const int MSGLEVEL_DEBUG = 2;
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Message() = default;
|
Message() = default;
|
||||||
Message(std::string msg, const unsigned int& type = MSGTYPE_INFO, const std::string& prefix = std::string())
|
Message(std::string msg, const unsigned int& type = MSGTYPE_INFO, const std::string& prefix = std::string(), const int& level = MSGLEVEL_DEFAULT)
|
||||||
{
|
{
|
||||||
prefix_ = prefix;
|
prefix_ = prefix;
|
||||||
msg_ = msg;
|
msg_ = msg;
|
||||||
type_ = type;
|
type_ = type;
|
||||||
timestamp_ = boost::posix_time::second_clock::local_time();
|
timestamp_ = boost::posix_time::second_clock::local_time();
|
||||||
|
level_ = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMessage(const std::string& msg)
|
void setMessage(const std::string& msg)
|
||||||
@ -46,6 +52,11 @@ class Message
|
|||||||
prefix_ = prefix;
|
prefix_ = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLevel(const int& level)
|
||||||
|
{
|
||||||
|
level_ = level;
|
||||||
|
}
|
||||||
|
|
||||||
std::string getMessage()
|
std::string getMessage()
|
||||||
{
|
{
|
||||||
return msg_;
|
return msg_;
|
||||||
@ -71,6 +82,11 @@ class Message
|
|||||||
return prefix_;
|
return prefix_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getLevel()
|
||||||
|
{
|
||||||
|
return level_;
|
||||||
|
}
|
||||||
|
|
||||||
std::string getFormattedString(const bool& bColor = true, const bool& bPrefix = true)
|
std::string getFormattedString(const bool& bColor = true, const bool& bPrefix = true)
|
||||||
{
|
{
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -103,6 +119,7 @@ class Message
|
|||||||
boost::posix_time::ptime timestamp_;
|
boost::posix_time::ptime timestamp_;
|
||||||
unsigned int type_;
|
unsigned int type_;
|
||||||
std::string prefix_;
|
std::string prefix_;
|
||||||
|
int level_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_H
|
#endif // MESSAGE_H
|
||||||
|
8
main.cpp
8
main.cpp
@ -254,7 +254,6 @@ int main(int argc, char *argv[])
|
|||||||
("no-color", bpo::value<bool>(&bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar or status messages")
|
("no-color", bpo::value<bool>(&bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar or status messages")
|
||||||
("no-duplicate-handling", bpo::value<bool>(&bNoDuplicateHandler)->zero_tokens()->default_value(false), "Don't use duplicate handler for installers\nDuplicate installers from different languages are handled separately")
|
("no-duplicate-handling", bpo::value<bool>(&bNoDuplicateHandler)->zero_tokens()->default_value(false), "Don't use duplicate handler for installers\nDuplicate installers from different languages are handled separately")
|
||||||
("no-subdirectories", bpo::value<bool>(&bNoSubDirectories)->zero_tokens()->default_value(false), "Don't create subdirectories for extras, patches and language packs")
|
("no-subdirectories", bpo::value<bool>(&bNoSubDirectories)->zero_tokens()->default_value(false), "Don't create subdirectories for extras, patches and language packs")
|
||||||
("verbose", bpo::value<bool>(&Globals::globalConfig.bVerbose)->zero_tokens()->default_value(false), "Print lots of information")
|
|
||||||
("curl-verbose", bpo::value<bool>(&Globals::globalConfig.curlConf.bVerbose)->zero_tokens()->default_value(false), "Set libcurl to verbose mode")
|
("curl-verbose", bpo::value<bool>(&Globals::globalConfig.curlConf.bVerbose)->zero_tokens()->default_value(false), "Set libcurl to verbose mode")
|
||||||
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
||||||
("timeout", bpo::value<long int>(&Globals::globalConfig.curlConf.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
("timeout", bpo::value<long int>(&Globals::globalConfig.curlConf.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
||||||
@ -283,6 +282,7 @@ int main(int argc, char *argv[])
|
|||||||
("lowspeed-rate", bpo::value<long int>(&Globals::globalConfig.curlConf.iLowSpeedTimeoutRate)->default_value(200), "Set average transfer speed in bytes per second that the transfer should be below during time specified with --lowspeed-timeout for it to be considered too slow and aborted")
|
("lowspeed-rate", bpo::value<long int>(&Globals::globalConfig.curlConf.iLowSpeedTimeoutRate)->default_value(200), "Set average transfer speed in bytes per second that the transfer should be below during time specified with --lowspeed-timeout for it to be considered too slow and aborted")
|
||||||
("include-hidden-products", bpo::value<bool>(&Globals::globalConfig.bIncludeHiddenProducts)->zero_tokens()->default_value(false), "Include games that have been set hidden in account page")
|
("include-hidden-products", bpo::value<bool>(&Globals::globalConfig.bIncludeHiddenProducts)->zero_tokens()->default_value(false), "Include games that have been set hidden in account page")
|
||||||
("size-only", bpo::value<bool>(&Globals::globalConfig.bSizeOnly)->zero_tokens()->default_value(false), "Don't check the hashes of the files whose size matches that on the server")
|
("size-only", bpo::value<bool>(&Globals::globalConfig.bSizeOnly)->zero_tokens()->default_value(false), "Don't check the hashes of the files whose size matches that on the server")
|
||||||
|
("verbosity", bpo::value<int>(&Globals::globalConfig.iMsgLevel)->default_value(0), "Set message verbosity level\n -1 = Less verbose\n 0 = Default\n 1 = Verbose\n 2 = Debug")
|
||||||
;
|
;
|
||||||
|
|
||||||
options_cli_no_cfg_hidden.add_options()
|
options_cli_no_cfg_hidden.add_options()
|
||||||
@ -499,6 +499,12 @@ int main(int argc, char *argv[])
|
|||||||
set_vm_value(vm, "threads", Globals::globalConfig.iThreads);
|
set_vm_value(vm, "threads", Globals::globalConfig.iThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Globals::globalConfig.iMsgLevel < -1)
|
||||||
|
{
|
||||||
|
Globals::globalConfig.iMsgLevel = -1;
|
||||||
|
set_vm_value(vm, "verbosity", Globals::globalConfig.iMsgLevel);
|
||||||
|
}
|
||||||
|
|
||||||
Globals::globalConfig.curlConf.bVerifyPeer = !bInsecure;
|
Globals::globalConfig.curlConf.bVerifyPeer = !bInsecure;
|
||||||
Globals::globalConfig.bColor = !bNoColor;
|
Globals::globalConfig.bColor = !bNoColor;
|
||||||
Globals::globalConfig.bUnicode = !bNoUnicode;
|
Globals::globalConfig.bUnicode = !bNoUnicode;
|
||||||
|
@ -482,7 +482,9 @@ int Downloader::getGameDetails()
|
|||||||
Message msg;
|
Message msg;
|
||||||
while (msgQueue.try_pop(msg))
|
while (msgQueue.try_pop(msg))
|
||||||
{
|
{
|
||||||
std::cerr << msg.getFormattedString(Globals::globalConfig.bColor, true) << std::endl;
|
if (msg.getLevel() <= Globals::globalConfig.iMsgLevel)
|
||||||
|
std::cerr << msg.getFormattedString(Globals::globalConfig.bColor, true) << std::endl;
|
||||||
|
|
||||||
if (Globals::globalConfig.bReport)
|
if (Globals::globalConfig.bReport)
|
||||||
{
|
{
|
||||||
this->report_ofs << msg.getTimestampString() << ": " << msg.getMessage() << std::endl;
|
this->report_ofs << msg.getTimestampString() << ": " << msg.getMessage() << std::endl;
|
||||||
@ -549,7 +551,7 @@ int Downloader::listGames()
|
|||||||
std::string filepath = games[i].installers[j].getFilepath();
|
std::string filepath = games[i].installers[j].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -575,7 +577,7 @@ int Downloader::listGames()
|
|||||||
std::string filepath = games[i].extras[j].getFilepath();
|
std::string filepath = games[i].extras[j].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -596,7 +598,7 @@ int Downloader::listGames()
|
|||||||
std::string filepath = games[i].patches[j].getFilepath();
|
std::string filepath = games[i].patches[j].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -622,7 +624,7 @@ int Downloader::listGames()
|
|||||||
std::string filepath = games[i].languagepacks[j].getFilepath();
|
std::string filepath = games[i].languagepacks[j].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -650,7 +652,7 @@ int Downloader::listGames()
|
|||||||
std::string filepath = games[i].dlcs[j].installers[k].getFilepath();
|
std::string filepath = games[i].dlcs[j].installers[k].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -669,7 +671,7 @@ int Downloader::listGames()
|
|||||||
{
|
{
|
||||||
std::string filepath = games[i].dlcs[j].patches[k].getFilepath();
|
std::string filepath = games[i].dlcs[j].patches[k].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath)) {
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath)) {
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -687,7 +689,7 @@ int Downloader::listGames()
|
|||||||
{
|
{
|
||||||
std::string filepath = games[i].dlcs[j].extras[k].getFilepath();
|
std::string filepath = games[i].dlcs[j].extras[k].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath)) {
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath)) {
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -704,7 +706,7 @@ int Downloader::listGames()
|
|||||||
{
|
{
|
||||||
std::string filepath = games[i].dlcs[j].languagepacks[k].getFilepath();
|
std::string filepath = games[i].dlcs[j].languagepacks[k].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath)) {
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath)) {
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -794,7 +796,7 @@ void Downloader::repair()
|
|||||||
std::string filepath = vGameFiles[i].getFilepath();
|
std::string filepath = vGameFiles[i].getFilepath();
|
||||||
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
if (Globals::globalConfig.blacklist.isBlacklisted(filepath))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
std::cerr << "skipped blacklisted file " << filepath << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1864,7 +1866,7 @@ void Downloader::checkOrphans()
|
|||||||
{
|
{
|
||||||
std::string filepath = dir_iter->path().string();
|
std::string filepath = dir_iter->path().string();
|
||||||
if (config.ignorelist.isBlacklisted(filepath.substr(pathlen))) {
|
if (config.ignorelist.isBlacklisted(filepath.substr(pathlen))) {
|
||||||
if (config.bVerbose)
|
if (config.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped ignorelisted file " << filepath << std::endl;
|
std::cerr << "skipped ignorelisted file " << filepath << std::endl;
|
||||||
} else {
|
} else {
|
||||||
boost::regex expression(config.sOrphanRegex); // Limit to files matching the regex
|
boost::regex expression(config.sOrphanRegex); // Limit to files matching the regex
|
||||||
@ -2605,14 +2607,14 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
{
|
{
|
||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CURL* dlhandle = curl_easy_init();
|
CURL* dlhandle = curl_easy_init();
|
||||||
|
|
||||||
Util::CurlHandleSetDefaultOptions(dlhandle, conf.curlConf);
|
Util::CurlHandleSetDefaultOptions(dlhandle, conf.curlConf);
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(dlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_READFUNCTION, Util::CurlReadChunkMemoryCallback);
|
curl_easy_setopt(dlhandle, CURLOPT_READFUNCTION, Util::CurlReadChunkMemoryCallback);
|
||||||
@ -2626,7 +2628,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
curl_easy_setopt(dlhandle, CURLOPT_XFERINFODATA, &xferinfo);
|
curl_easy_setopt(dlhandle, CURLOPT_XFERINFODATA, &xferinfo);
|
||||||
|
|
||||||
cloudSaveFile csf;
|
cloudSaveFile csf;
|
||||||
|
|
||||||
std::string access_token;
|
std::string access_token;
|
||||||
if (!Globals::galaxyConf.isExpired()) {
|
if (!Globals::galaxyConf.isExpired()) {
|
||||||
access_token = Globals::galaxyConf.getAccessToken();
|
access_token = Globals::galaxyConf.getAccessToken();
|
||||||
@ -2659,7 +2661,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
&filecontents[0],
|
&filecontents[0],
|
||||||
(curl_off_t)filecontents.size()
|
(curl_off_t)filecontents.size()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto md5 = Util::getChunkHash((std::uint8_t*)filecontents.data(), filecontents.size(), RHASH_MD5);
|
auto md5 = Util::getChunkHash((std::uint8_t*)filecontents.data(), filecontents.size(), RHASH_MD5);
|
||||||
|
|
||||||
auto url = "https://cloudstorage.gog.com/v1/" + Globals::galaxyConf.getUserId() + '/' + Globals::galaxyConf.getClientId() + '/' + csf.path;
|
auto url = "https://cloudstorage.gog.com/v1/" + Globals::galaxyConf.getUserId() + '/' + Globals::galaxyConf.getClientId() + '/' + csf.path;
|
||||||
@ -2677,7 +2679,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
curl_easy_setopt(dlhandle, CURLOPT_READDATA, &cms);
|
curl_easy_setopt(dlhandle, CURLOPT_READDATA, &cms);
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(dlhandle, CURLOPT_URL, url.c_str());
|
||||||
|
|
||||||
msgQueue.push(Message("Begin upload: " + csf.path, MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Begin upload: " + csf.path, MSGTYPE_INFO, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
|
|
||||||
bool bShouldRetry = false;
|
bool bShouldRetry = false;
|
||||||
long int response_code = 0;
|
long int response_code = 0;
|
||||||
@ -2694,7 +2696,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + boost::filesystem::path(csf.location).filename().string();
|
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + boost::filesystem::path(csf.location).filename().string();
|
||||||
if (!retry_reason.empty())
|
if (!retry_reason.empty())
|
||||||
retry_msg += " (" + retry_reason + ")";
|
retry_msg += " (" + retry_reason + ")";
|
||||||
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
retry_reason.clear(); // reset retry reason
|
retry_reason.clear(); // reset retry reason
|
||||||
|
|
||||||
@ -2716,7 +2718,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
case CURLE_HTTP_RETURNED_ERROR:
|
case CURLE_HTTP_RETURNED_ERROR:
|
||||||
curl_easy_getinfo(dlhandle, CURLINFO_RESPONSE_CODE, &response_code);
|
curl_easy_getinfo(dlhandle, CURLINFO_RESPONSE_CODE, &response_code);
|
||||||
if (response_code == 416 || response_code == 422 || response_code == 400 || response_code == 422) {
|
if (response_code == 416 || response_code == 422 || response_code == 400 || response_code == 422) {
|
||||||
msgQueue.push(Message(std::to_string(response_code) + ": " + curl_easy_strerror(result)));
|
msgQueue.push(Message(std::to_string(response_code) + ": " + curl_easy_strerror(result), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
bShouldRetry = false;
|
bShouldRetry = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2739,7 +2741,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
curl_easy_cleanup(dlhandle);
|
curl_easy_cleanup(dlhandle);
|
||||||
|
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
msgQueue.push(Message("Finished all tasks", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Finished all tasks", MSGTYPE_INFO, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int& tid) {
|
void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int& tid) {
|
||||||
@ -2750,14 +2752,14 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
{
|
{
|
||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CURL* dlhandle = curl_easy_init();
|
CURL* dlhandle = curl_easy_init();
|
||||||
|
|
||||||
Util::CurlHandleSetDefaultOptions(dlhandle, conf.curlConf);
|
Util::CurlHandleSetDefaultOptions(dlhandle, conf.curlConf);
|
||||||
|
|
||||||
curl_slist *header = nullptr;
|
curl_slist *header = nullptr;
|
||||||
@ -2802,20 +2804,20 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
|
|
||||||
bResume = boost::filesystem::exists(filepath);
|
bResume = boost::filesystem::exists(filepath);
|
||||||
|
|
||||||
msgQueue.push(Message("Begin download: " + csf.path, MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Begin download: " + csf.path, MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
|
|
||||||
// Check that directory exists and create subdirectories
|
// Check that directory exists and create subdirectories
|
||||||
std::unique_lock<std::mutex> ul { mtx_create_directories }; // Use mutex to avoid possible race conditions
|
std::unique_lock<std::mutex> ul { mtx_create_directories }; // Use mutex to avoid possible race conditions
|
||||||
if (boost::filesystem::exists(directory))
|
if (boost::filesystem::exists(directory))
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(directory)) {
|
if (!boost::filesystem::is_directory(directory)) {
|
||||||
msgQueue.push(Message(directory.string() + " is not directory, skipping file (" + filepath.filename().string() + ")", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(directory.string() + " is not directory, skipping file (" + filepath.filename().string() + ")", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!boost::filesystem::create_directories(directory))
|
else if (!boost::filesystem::create_directories(directory))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create directory (" + directory.string() + "), skipping file (" + filepath.filename().string() + ")", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create directory (" + directory.string() + "), skipping file (" + filepath.filename().string() + ")", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2837,7 +2839,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + filepath.filename().string();
|
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + filepath.filename().string();
|
||||||
if (!retry_reason.empty())
|
if (!retry_reason.empty())
|
||||||
retry_msg += " (" + retry_reason + ")";
|
retry_msg += " (" + retry_reason + ")";
|
||||||
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
retry_reason = ""; // reset retry reason
|
retry_reason = ""; // reset retry reason
|
||||||
|
|
||||||
@ -2854,7 +2856,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to open " + filepath.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to open " + filepath.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2867,7 +2869,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create " + filepath.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create " + filepath.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2927,7 +2929,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
}
|
}
|
||||||
catch(const boost::filesystem::filesystem_error& e)
|
catch(const boost::filesystem::filesystem_error& e)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(e.what(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(e.what(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2947,7 +2949,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
}
|
}
|
||||||
dlrate_avg << std::setprecision(2) << std::fixed << progress_info.rate_avg << rate_unit;
|
dlrate_avg << std::setprecision(2) << std::fixed << progress_info.rate_avg << rate_unit;
|
||||||
|
|
||||||
msgQueue.push(Message("Download complete: " + csf.path + " (@ " + dlrate_avg.str() + ")", MSGTYPE_SUCCESS, msg_prefix));
|
msgQueue.push(Message("Download complete: " + csf.path + " (@ " + dlrate_avg.str() + ")", MSGTYPE_SUCCESS, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2955,7 +2957,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
if (response_code > 0)
|
if (response_code > 0)
|
||||||
msg += " (" + std::to_string(response_code) + ")";
|
msg += " (" + std::to_string(response_code) + ")";
|
||||||
msg += "): " + filepath.filename().string();
|
msg += "): " + filepath.filename().string();
|
||||||
msgQueue.push(Message(msg, MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(msg, MSGTYPE_WARNING, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
|
|
||||||
// Delete the file if download failed and was not a resume attempt or the result is zero length file
|
// Delete the file if download failed and was not a resume attempt or the result is zero length file
|
||||||
if (boost::filesystem::exists(filepath) && boost::filesystem::is_regular_file(filepath))
|
if (boost::filesystem::exists(filepath) && boost::filesystem::is_regular_file(filepath))
|
||||||
@ -2963,7 +2965,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
if ((result != CURLE_PARTIAL_FILE && !bResume && result != CURLE_OPERATION_TIMEDOUT) || boost::filesystem::file_size(filepath) == 0)
|
if ((result != CURLE_PARTIAL_FILE && !bResume && result != CURLE_OPERATION_TIMEDOUT) || boost::filesystem::file_size(filepath) == 0)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::remove(filepath))
|
if (!boost::filesystem::remove(filepath))
|
||||||
msgQueue.push(Message("Failed to delete " + filepath.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to delete " + filepath.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2973,7 +2975,7 @@ void Downloader::processCloudSaveDownloadQueue(Config conf, const unsigned int&
|
|||||||
curl_easy_cleanup(dlhandle);
|
curl_easy_cleanup(dlhandle);
|
||||||
|
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
msgQueue.push(Message("Finished all tasks", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Finished all tasks", MSGTYPE_INFO, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
||||||
@ -2986,7 +2988,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3034,7 +3036,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
// Skip blacklisted files
|
// Skip blacklisted files
|
||||||
if (conf.blacklist.isBlacklisted(filepath.string()))
|
if (conf.blacklist.isBlacklisted(filepath.string()))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Blacklisted file: " + filepath.string(), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Blacklisted file: " + filepath.string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3043,7 +3045,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
boost::filesystem::path local_xml_file = xml_directory + "/" + filenameXML;
|
boost::filesystem::path local_xml_file = xml_directory + "/" + filenameXML;
|
||||||
|
|
||||||
vDownloadInfo[tid].setFilename(filepath.filename().string());
|
vDownloadInfo[tid].setFilename(filepath.filename().string());
|
||||||
msgQueue.push(Message("Begin download: " + filepath.filename().string(), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Begin download: " + filepath.filename().string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
|
|
||||||
// Check that directory exists and create subdirectories
|
// Check that directory exists and create subdirectories
|
||||||
mtx_create_directories.lock(); // Use mutex to avoid possible race conditions
|
mtx_create_directories.lock(); // Use mutex to avoid possible race conditions
|
||||||
@ -3052,7 +3054,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
if (!boost::filesystem::is_directory(directory))
|
if (!boost::filesystem::is_directory(directory))
|
||||||
{
|
{
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
msgQueue.push(Message(directory.string() + " is not directory, skipping file (" + filepath.filename().string() + ")", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(directory.string() + " is not directory, skipping file (" + filepath.filename().string() + ")", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3065,7 +3067,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
if (!boost::filesystem::create_directories(directory))
|
if (!boost::filesystem::create_directories(directory))
|
||||||
{
|
{
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
msgQueue.push(Message("Failed to create directory (" + directory.string() + "), skipping file (" + filepath.filename().string() + ")", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create directory (" + directory.string() + "), skipping file (" + filepath.filename().string() + ")", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3082,7 +3084,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
{
|
{
|
||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
return;
|
return;
|
||||||
@ -3094,13 +3096,13 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
|
|
||||||
if (downlinkJson.empty())
|
if (downlinkJson.empty())
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Empty JSON response, skipping file", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message("Empty JSON response, skipping file", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!downlinkJson.isMember("downlink"))
|
if (!downlinkJson.isMember("downlink"))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Invalid JSON response, skipping file", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message("Invalid JSON response, skipping file", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3165,7 +3167,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
if (filesize_local == filesize_xml)
|
if (filesize_local == filesize_xml)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Skipping complete file: " + filepath.filename().string(), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Skipping complete file: " + filepath.filename().string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
bIsComplete = true; // Set to true so we can skip after saving xml data
|
bIsComplete = true; // Set to true so we can skip after saving xml data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3173,14 +3175,14 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Remote file is different, renaming local file", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Remote file is different, renaming local file", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
std::string date_old = "." + bptime::to_iso_string(bptime::second_clock::local_time()) + ".old";
|
std::string date_old = "." + bptime::to_iso_string(bptime::second_clock::local_time()) + ".old";
|
||||||
boost::filesystem::path new_name = filepath.string() + date_old; // Rename old file by appending date and ".old" to filename
|
boost::filesystem::path new_name = filepath.string() + date_old; // Rename old file by appending date and ".old" to filename
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
boost::filesystem::rename(filepath, new_name, ec); // Rename the file
|
boost::filesystem::rename(filepath, new_name, ec); // Rename the file
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to rename " + filepath.string() + " to " + new_name.string() + " - Skipping file", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message("Failed to rename " + filepath.string() + " to " + new_name.string() + " - Skipping file", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3198,14 +3200,14 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(path))
|
if (!boost::filesystem::is_directory(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + " is not directory", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(path.string() + " is not directory", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::create_directories(path))
|
if (!boost::filesystem::create_directories(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create directory: " + path.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create directory: " + path.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
@ -3217,7 +3219,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Can't create " + local_xml_file.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Can't create " + local_xml_file.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3243,7 +3245,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + filepath.filename().string();
|
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + filepath.filename().string();
|
||||||
if (!retry_reason.empty())
|
if (!retry_reason.empty())
|
||||||
retry_msg += " (" + retry_reason + ")";
|
retry_msg += " (" + retry_reason + ")";
|
||||||
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
retry_reason = ""; // reset retry reason
|
retry_reason = ""; // reset retry reason
|
||||||
|
|
||||||
@ -3260,7 +3262,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to open " + filepath.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to open " + filepath.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3273,7 +3275,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create " + filepath.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create " + filepath.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3330,7 +3332,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
catch(const boost::filesystem::filesystem_error& e)
|
catch(const boost::filesystem::filesystem_error& e)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(e.what(), MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(e.what(), MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3350,7 +3352,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
dlrate_avg << std::setprecision(2) << std::fixed << progress_info.rate_avg << rate_unit;
|
dlrate_avg << std::setprecision(2) << std::fixed << progress_info.rate_avg << rate_unit;
|
||||||
|
|
||||||
msgQueue.push(Message("Download complete: " + filepath.filename().string() + " (@ " + dlrate_avg.str() + ")", MSGTYPE_SUCCESS, msg_prefix));
|
msgQueue.push(Message("Download complete: " + filepath.filename().string() + " (@ " + dlrate_avg.str() + ")", MSGTYPE_SUCCESS, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3358,7 +3360,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
if (response_code > 0)
|
if (response_code > 0)
|
||||||
msg += " (" + std::to_string(response_code) + ")";
|
msg += " (" + std::to_string(response_code) + ")";
|
||||||
msg += "): " + filepath.filename().string();
|
msg += "): " + filepath.filename().string();
|
||||||
msgQueue.push(Message(msg, MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(msg, MSGTYPE_WARNING, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
|
|
||||||
// Delete the file if download failed and was not a resume attempt or the result is zero length file
|
// Delete the file if download failed and was not a resume attempt or the result is zero length file
|
||||||
if (boost::filesystem::exists(filepath) && boost::filesystem::is_regular_file(filepath))
|
if (boost::filesystem::exists(filepath) && boost::filesystem::is_regular_file(filepath))
|
||||||
@ -3366,7 +3368,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
if ((result != CURLE_PARTIAL_FILE && !bResume && result != CURLE_OPERATION_TIMEDOUT) || boost::filesystem::file_size(filepath) == 0)
|
if ((result != CURLE_PARTIAL_FILE && !bResume && result != CURLE_OPERATION_TIMEDOUT) || boost::filesystem::file_size(filepath) == 0)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::remove(filepath))
|
if (!boost::filesystem::remove(filepath))
|
||||||
msgQueue.push(Message("Failed to delete " + filepath.filename().string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to delete " + filepath.filename().string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3386,7 +3388,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
|||||||
delete galaxy;
|
delete galaxy;
|
||||||
|
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
msgQueue.push(Message("Finished all tasks", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Finished all tasks", MSGTYPE_INFO, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3459,7 +3461,9 @@ template <typename T> void Downloader::printProgress(const ThreadSafeQueue<T>& d
|
|||||||
Message msg;
|
Message msg;
|
||||||
while (msgQueue.try_pop(msg))
|
while (msgQueue.try_pop(msg))
|
||||||
{
|
{
|
||||||
std::cout << msg.getFormattedString(Globals::globalConfig.bColor, true) << std::endl;
|
if (msg.getLevel() <= Globals::globalConfig.iMsgLevel)
|
||||||
|
std::cout << msg.getFormattedString(Globals::globalConfig.bColor, true) << std::endl;
|
||||||
|
|
||||||
if (Globals::globalConfig.bReport)
|
if (Globals::globalConfig.bReport)
|
||||||
{
|
{
|
||||||
this->report_ofs << msg.getTimestampString() << ": " << msg.getMessage() << std::endl;
|
this->report_ofs << msg.getTimestampString() << ": " << msg.getMessage() << std::endl;
|
||||||
@ -3610,7 +3614,7 @@ void Downloader::getGameDetailsThread(Config config, const unsigned int& tid)
|
|||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3622,7 +3626,7 @@ void Downloader::getGameDetailsThread(Config config, const unsigned int& tid)
|
|||||||
{
|
{
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
delete website;
|
delete website;
|
||||||
msgQueue.push(Message("Website not logged in", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Website not logged in", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3648,7 +3652,7 @@ void Downloader::getGameDetailsThread(Config config, const unsigned int& tid)
|
|||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << game_item.name << " - " << iOptionsOverridden << " options overridden with game specific options" << std::endl;
|
ss << game_item.name << " - " << iOptionsOverridden << " options overridden with game specific options" << std::endl;
|
||||||
if (config.bVerbose)
|
if (config.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
{
|
{
|
||||||
if (conf.dlConf.bIgnoreDLCCount)
|
if (conf.dlConf.bIgnoreDLCCount)
|
||||||
ss << "\tIgnore DLC count" << std::endl;
|
ss << "\tIgnore DLC count" << std::endl;
|
||||||
@ -3675,7 +3679,7 @@ void Downloader::getGameDetailsThread(Config config, const unsigned int& tid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msgQueue.push(Message(ss.str(), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(ss.str(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3684,7 +3688,7 @@ void Downloader::getGameDetailsThread(Config config, const unsigned int& tid)
|
|||||||
{
|
{
|
||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4029,7 +4033,7 @@ void Downloader::galaxyInstallGameById(const std::string& product_id, int build_
|
|||||||
uintmax_t totalSize = 0;
|
uintmax_t totalSize = 0;
|
||||||
for (unsigned int i = 0; i < items.size(); ++i)
|
for (unsigned int i = 0; i < items.size(); ++i)
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
{
|
{
|
||||||
std::cout << items[i].path << std::endl;
|
std::cout << items[i].path << std::endl;
|
||||||
std::cout << "\tChunks: " << items[i].chunks.size() << std::endl;
|
std::cout << "\tChunks: " << items[i].chunks.size() << std::endl;
|
||||||
@ -4095,7 +4099,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4135,7 +4139,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(directory))
|
if (!boost::filesystem::is_directory(directory))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(directory.string() + " is not directory", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(directory.string() + " is not directory", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
@ -4146,7 +4150,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::create_directories(directory))
|
if (!boost::filesystem::create_directories(directory))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create directory: " + directory.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create directory: " + directory.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
@ -4160,8 +4164,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
unsigned int start_chunk = 0;
|
unsigned int start_chunk = 0;
|
||||||
if (boost::filesystem::exists(path))
|
if (boost::filesystem::exists(path))
|
||||||
{
|
{
|
||||||
if (conf.bVerbose)
|
msgQueue.push(Message("File already exists: " + path.string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
msgQueue.push(Message("File already exists: " + path.string(), MSGTYPE_INFO, msg_prefix));
|
|
||||||
|
|
||||||
unsigned int resume_chunk = 0;
|
unsigned int resume_chunk = 0;
|
||||||
uintmax_t filesize = boost::filesystem::file_size(path);
|
uintmax_t filesize = boost::filesystem::file_size(path);
|
||||||
@ -4170,15 +4173,15 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
// File is same size
|
// File is same size
|
||||||
if (Util::getFileHash(path.string(), RHASH_MD5) == item.md5)
|
if (Util::getFileHash(path.string(), RHASH_MD5) == item.md5)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": OK", MSGTYPE_SUCCESS, msg_prefix));
|
msgQueue.push(Message(path.string() + ": OK", MSGTYPE_SUCCESS, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": MD5 mismatch", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(path.string() + ": MD5 mismatch", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4186,10 +4189,10 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
else if (filesize > item.totalSizeUncompressed)
|
else if (filesize > item.totalSizeUncompressed)
|
||||||
{
|
{
|
||||||
// File is bigger than on server, delete old file and start from beginning
|
// File is bigger than on server, delete old file and start from beginning
|
||||||
msgQueue.push(Message(path.string() + ": File is bigger than expected. Deleting old file and starting from beginning", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path.string() + ": File is bigger than expected. Deleting old file and starting from beginning", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4207,12 +4210,12 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
|
|
||||||
if (resume_chunk > 0)
|
if (resume_chunk > 0)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Resume from chunk " + std::to_string(resume_chunk), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Resume from chunk " + std::to_string(resume_chunk), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
// Get chunk hash for previous chunk
|
// Get chunk hash for previous chunk
|
||||||
FILE* f = fopen(path.string().c_str(), "r");
|
FILE* f = fopen(path.string().c_str(), "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to open", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to open", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4223,7 +4226,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
unsigned char *chunk = (unsigned char *) malloc(chunk_size * sizeof(unsigned char *));
|
unsigned char *chunk = (unsigned char *) malloc(chunk_size * sizeof(unsigned char *));
|
||||||
if (chunk == NULL)
|
if (chunk == NULL)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Memory error - Chunk " + std::to_string(resume_chunk), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Memory error - Chunk " + std::to_string(resume_chunk), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -4233,7 +4236,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
|
|
||||||
if (fread_size != chunk_size)
|
if (fread_size != chunk_size)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Read error - Chunk " + std::to_string(resume_chunk), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Read error - Chunk " + std::to_string(resume_chunk), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
free(chunk);
|
free(chunk);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -4248,20 +4251,20 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Hash for previous chunk is different, delete old file and start from beginning
|
// Hash for previous chunk is different, delete old file and start from beginning
|
||||||
msgQueue.push(Message(path.string() + ": Chunk hash is different. Deleting old file and starting from beginning.", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Chunk hash is different. Deleting old file and starting from beginning.", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to find valid resume position. Deleting old file and starting from beginning.", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to find valid resume position. Deleting old file and starting from beginning.", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4277,7 +4280,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
{
|
{
|
||||||
if (!galaxy->refreshLogin())
|
if (!galaxy->refreshLogin())
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Galaxy API failed to refresh login", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
delete galaxy;
|
delete galaxy;
|
||||||
return;
|
return;
|
||||||
@ -4300,7 +4303,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
{
|
{
|
||||||
bChunkFailure = true;
|
bChunkFailure = true;
|
||||||
std::string error_message = path.string() + ": Empty JSON response (product: " + item.product_id + ", chunk #"+ std::to_string(j) + ": " + item.chunks[j].md5_compressed + ")";
|
std::string error_message = path.string() + ": Empty JSON response (product: " + item.product_id + ", chunk #"+ std::to_string(j) + ": " + item.chunks[j].md5_compressed + ")";
|
||||||
msgQueue.push(Message(error_message, MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(error_message, MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4310,7 +4313,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
if (cdnUrlTemplates.empty())
|
if (cdnUrlTemplates.empty())
|
||||||
{
|
{
|
||||||
bChunkFailure = true;
|
bChunkFailure = true;
|
||||||
msgQueue.push(Message(path.string() + ": Failed to get download url", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to get download url", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4360,7 +4363,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + filepath_and_chunk;
|
std::string retry_msg = "Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + filepath_and_chunk;
|
||||||
if (!retry_reason.empty())
|
if (!retry_reason.empty())
|
||||||
retry_msg += " (" + retry_reason + ")";
|
retry_msg += " (" + retry_reason + ")";
|
||||||
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(retry_msg, MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
|
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_RESUME_FROM_LARGE, chunk.size);
|
curl_easy_setopt(dlhandle, CURLOPT_RESUME_FROM_LARGE, chunk.size);
|
||||||
}
|
}
|
||||||
@ -4406,15 +4409,15 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
|
|
||||||
if (result != CURLE_OK)
|
if (result != CURLE_OK)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(std::string(curl_easy_strerror(result)), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(std::string(curl_easy_strerror(result)), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (result == CURLE_HTTP_RETURNED_ERROR)
|
if (result == CURLE_HTTP_RETURNED_ERROR)
|
||||||
{
|
{
|
||||||
long int response_code = 0;
|
long int response_code = 0;
|
||||||
result = curl_easy_getinfo(dlhandle, CURLINFO_RESPONSE_CODE, &response_code);
|
result = curl_easy_getinfo(dlhandle, CURLINFO_RESPONSE_CODE, &response_code);
|
||||||
if (result == CURLE_OK)
|
if (result == CURLE_OK)
|
||||||
msgQueue.push(Message("HTTP ERROR: " + std::to_string(response_code) + " (" + url + ")", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("HTTP ERROR: " + std::to_string(response_code) + " (" + url + ")", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
else
|
else
|
||||||
msgQueue.push(Message("HTTP ERROR: failed to get error code: " + std::string(curl_easy_strerror(result)) + " (" + url + ")", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("HTTP ERROR: failed to get error code: " + std::string(curl_easy_strerror(result)) + " (" + url + ")", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4442,7 +4445,7 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
|
|
||||||
if (bChunkFailure)
|
if (bChunkFailure)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Chunk failure, skipping file", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Chunk failure, skipping file", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4455,11 +4458,11 @@ void Downloader::processGalaxyDownloadQueue(const std::string& install_path, Con
|
|||||||
}
|
}
|
||||||
catch(const boost::filesystem::filesystem_error& e)
|
catch(const boost::filesystem::filesystem_error& e)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(e.what(), MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(e.what(), MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msgQueue.push(Message("Download complete: " + path.string(), MSGTYPE_SUCCESS, msg_prefix));
|
msgQueue.push(Message("Download complete: " + path.string(), MSGTYPE_SUCCESS, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
@ -4769,10 +4772,10 @@ int Downloader::cloudSaveListByIdForEach(const std::string& product_id, int buil
|
|||||||
std::cout << "No cloud save locations found" << std::endl;
|
std::cout << "No cloud save locations found" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string url = "https://cloudstorage.gog.com/v1/" + Globals::galaxyConf.getUserId() + "/" + Globals::galaxyConf.getClientId();
|
std::string url = "https://cloudstorage.gog.com/v1/" + Globals::galaxyConf.getUserId() + "/" + Globals::galaxyConf.getClientId();
|
||||||
auto fileList = gogGalaxy->getResponseJson(url, "application/json");
|
auto fileList = gogGalaxy->getResponseJson(url, "application/json");
|
||||||
|
|
||||||
for(auto &fileJson : fileList) {
|
for(auto &fileJson : fileList) {
|
||||||
auto path = fileJson["name"].asString();
|
auto path = fileJson["name"].asString();
|
||||||
|
|
||||||
@ -5121,7 +5124,7 @@ std::vector<std::string> Downloader::galaxyGetOrphanedFiles(const std::vector<ga
|
|||||||
std::string filepath = dir_iter->path().string();
|
std::string filepath = dir_iter->path().string();
|
||||||
if (Globals::globalConfig.ignorelist.isBlacklisted(filepath.substr(pathlen)))
|
if (Globals::globalConfig.ignorelist.isBlacklisted(filepath.substr(pathlen)))
|
||||||
{
|
{
|
||||||
if (Globals::globalConfig.bVerbose)
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
std::cerr << "skipped ignorelisted file " << filepath << std::endl;
|
std::cerr << "skipped ignorelisted file " << filepath << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -5587,7 +5590,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory(directory))
|
if (!boost::filesystem::is_directory(directory))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(directory.string() + " is not directory", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(directory.string() + " is not directory", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
return;
|
return;
|
||||||
@ -5597,7 +5600,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::create_directories(directory))
|
if (!boost::filesystem::create_directories(directory))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create directory: " + directory.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create directory: " + directory.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
mtx_create_directories.unlock();
|
mtx_create_directories.unlock();
|
||||||
return;
|
return;
|
||||||
@ -5611,7 +5614,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
if (boost::filesystem::is_symlink(path))
|
if (boost::filesystem::is_symlink(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Symlink already exists: " + path.string(), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Symlink already exists: " + path.string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5621,25 +5624,24 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
if (boost::filesystem::exists(zfe.splitFileBasePath))
|
if (boost::filesystem::exists(zfe.splitFileBasePath))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Complete file (" + zfe.splitFileBasePath + ") of split file exists. Checking if it is same version.", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Complete file (" + zfe.splitFileBasePath + ") of split file exists. Checking if it is same version.", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
|
|
||||||
std::string crc32 = Util::getFileHashRange(zfe.splitFileBasePath, RHASH_CRC32, zfe.splitFileStartOffset, zfe.splitFileEndOffset);
|
std::string crc32 = Util::getFileHashRange(zfe.splitFileBasePath, RHASH_CRC32, zfe.splitFileStartOffset, zfe.splitFileEndOffset);
|
||||||
if (crc32 == Util::formattedString("%08x", zfe.crc32))
|
if (crc32 == Util::formattedString("%08x", zfe.crc32))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Complete file (" + zfe.splitFileBasePath + ") of split file is same version. Skipping file.", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Complete file (" + zfe.splitFileBasePath + ") of split file is same version. Skipping file.", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Complete file (" + zfe.splitFileBasePath + ") of split file is different version. Continuing to download file.", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Complete file (" + zfe.splitFileBasePath + ") of split file is different version. Continuing to download file.", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost::filesystem::exists(path))
|
if (boost::filesystem::exists(path))
|
||||||
{
|
{
|
||||||
if (conf.bVerbose)
|
msgQueue.push(Message("File already exists: " + path.string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
msgQueue.push(Message("File already exists: " + path.string(), MSGTYPE_INFO, msg_prefix));
|
|
||||||
|
|
||||||
off_t filesize = static_cast<off_t>(boost::filesystem::file_size(path));
|
off_t filesize = static_cast<off_t>(boost::filesystem::file_size(path));
|
||||||
if (filesize == zfe.uncomp_size)
|
if (filesize == zfe.uncomp_size)
|
||||||
@ -5647,15 +5649,15 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
// File is same size
|
// File is same size
|
||||||
if (Util::getFileHash(path.string(), RHASH_CRC32) == Util::formattedString("%08x", zfe.crc32))
|
if (Util::getFileHash(path.string(), RHASH_CRC32) == Util::formattedString("%08x", zfe.crc32))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": OK", MSGTYPE_SUCCESS, msg_prefix));
|
msgQueue.push(Message(path.string() + ": OK", MSGTYPE_SUCCESS, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": CRC32 mismatch. Deleting old file.", MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(path.string() + ": CRC32 mismatch. Deleting old file.", MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5663,10 +5665,10 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// File size mismatch
|
// File size mismatch
|
||||||
msgQueue.push(Message(path.string() + ": File size mismatch. Deleting old file.", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path.string() + ": File size mismatch. Deleting old file.", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5685,10 +5687,10 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Delete old file
|
// Delete old file
|
||||||
msgQueue.push(Message(path_tmp.string() + ": Deleting old file.", MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message(path_tmp.string() + ": Deleting old file.", MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
if (!boost::filesystem::remove(path_tmp))
|
if (!boost::filesystem::remove(path_tmp))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path_tmp.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path_tmp.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5723,7 +5725,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
if (result != CURLE_OK)
|
if (result != CURLE_OK)
|
||||||
{
|
{
|
||||||
symlink_compressed.str(std::string());
|
symlink_compressed.str(std::string());
|
||||||
msgQueue.push(Message(path.string() + ": Failed to download", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to download", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5753,7 +5755,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
msg += ")";
|
msg += ")";
|
||||||
|
|
||||||
msgQueue.push(Message(msg + " " + path.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(msg + " " + path.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
symlink_uncompressed.str(std::string());
|
symlink_uncompressed.str(std::string());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -5765,8 +5767,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::exists(path))
|
if (!boost::filesystem::exists(path))
|
||||||
{
|
{
|
||||||
if (conf.bVerbose)
|
msgQueue.push(Message(path.string() + ": Creating symlink to " + link_target, MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
msgQueue.push(Message(path.string() + ": Creating symlink to " + link_target, MSGTYPE_INFO, msg_prefix));
|
|
||||||
boost::filesystem::create_symlink(link_target, path);
|
boost::filesystem::create_symlink(link_target, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5782,7 +5783,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
std::ofstream ofs(path.string(), std::ofstream::out | std::ofstream::binary);
|
std::ofstream ofs(path.string(), std::ofstream::out | std::ofstream::binary);
|
||||||
if (!ofs)
|
if (!ofs)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5802,12 +5803,12 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
data_compressed.str(std::string());
|
data_compressed.str(std::string());
|
||||||
ofs.close();
|
ofs.close();
|
||||||
msgQueue.push(Message(path.string() + ": Failed to download", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to download", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path))
|
if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path))
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -5840,13 +5841,13 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
msg += ")";
|
msg += ")";
|
||||||
|
|
||||||
msgQueue.push(Message(msg + " " + path.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(msg + " " + path.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
data_compressed.str(std::string());
|
data_compressed.str(std::string());
|
||||||
if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path))
|
if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path))
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::remove(path))
|
if (!boost::filesystem::remove(path))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -5867,7 +5868,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
catch(const boost::filesystem::filesystem_error& e)
|
catch(const boost::filesystem::filesystem_error& e)
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(e.what(), MSGTYPE_WARNING, msg_prefix));
|
msgQueue.push(Message(e.what(), MSGTYPE_WARNING, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5882,7 +5883,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (iRetryCount != 0)
|
if (iRetryCount != 0)
|
||||||
msgQueue.push(Message("Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + path_tmp.filename().string(), MSGTYPE_INFO, msg_prefix));
|
msgQueue.push(Message("Retry " + std::to_string(iRetryCount) + "/" + std::to_string(conf.iRetries) + ": " + path_tmp.filename().string(), MSGTYPE_INFO, msg_prefix, MSGLEVEL_VERBOSE));
|
||||||
|
|
||||||
|
|
||||||
FILE* outfile;
|
FILE* outfile;
|
||||||
@ -5898,7 +5899,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to open " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to open " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5911,7 +5912,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Failed to create " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Failed to create " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5969,7 +5970,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
msg += ")";
|
msg += ")";
|
||||||
|
|
||||||
msgQueue.push(Message(msg + " " + path_tmp.string(), msg_type, msg_prefix));
|
msgQueue.push(Message(msg + " " + path_tmp.string(), msg_type, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bFailed)
|
if (bFailed)
|
||||||
@ -5979,7 +5980,7 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
{
|
{
|
||||||
if (!boost::filesystem::remove(path_tmp))
|
if (!boost::filesystem::remove(path_tmp))
|
||||||
{
|
{
|
||||||
msgQueue.push(Message(path_tmp.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message(path_tmp.string() + ": Failed to delete", MSGTYPE_ERROR, msg_prefix, MSGLEVEL_ALWAYS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5990,13 +5991,13 @@ void Downloader::processGalaxyDownloadQueue_MojoSetupHack(Config conf, const uns
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgQueue.push(Message("Download failed " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix));
|
msgQueue.push(Message("Download failed " + path_tmp.string(), MSGTYPE_ERROR, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msgQueue.push(Message("Download complete: " + path.string(), MSGTYPE_SUCCESS, msg_prefix));
|
msgQueue.push(Message("Download complete: " + path.string(), MSGTYPE_SUCCESS, msg_prefix, MSGLEVEL_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
vDownloadInfo[tid].setStatus(DLSTATUS_FINISHED);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* http://www.wtfpl.net/ for more details. */
|
* http://www.wtfpl.net/ for more details. */
|
||||||
|
|
||||||
#include "galaxyapi.h"
|
#include "galaxyapi.h"
|
||||||
|
#include "message.h"
|
||||||
#include "ziputil.h"
|
#include "ziputil.h"
|
||||||
|
|
||||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||||
@ -120,7 +121,8 @@ std::string galaxyAPI::getResponse(const std::string& url, const char *encoding)
|
|||||||
long int response_code = 0;
|
long int response_code = 0;
|
||||||
curl_easy_getinfo(curlhandle, CURLINFO_RESPONSE_CODE, &response_code);
|
curl_easy_getinfo(curlhandle, CURLINFO_RESPONSE_CODE, &response_code);
|
||||||
|
|
||||||
std::cout << "Response code for " << url << " is [" << response_code << ']' << std::endl;
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_VERBOSE)
|
||||||
|
std::cout << "Response code for " << url << " is [" << response_code << ']' << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_ACCEPT_ENCODING, NULL);
|
curl_easy_setopt(curlhandle, CURLOPT_ACCEPT_ENCODING, NULL);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "website.h"
|
#include "website.h"
|
||||||
#include "globalconstants.h"
|
#include "globalconstants.h"
|
||||||
|
#include "message.h"
|
||||||
|
|
||||||
#include <htmlcxx/html/ParserDom.h>
|
#include <htmlcxx/html/ParserDom.h>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
@ -71,14 +72,13 @@ Json::Value Website::getGameDetailsJSON(const std::string& gameid)
|
|||||||
try {
|
try {
|
||||||
json_stream >> root;
|
json_stream >> root;
|
||||||
} catch(const Json::Exception& exc) {
|
} catch(const Json::Exception& exc) {
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
std::cerr << "DEBUG INFO (Website::getGameDetailsJSON)" << std::endl << json << std::endl;
|
std::cerr << "DEBUG INFO (Website::getGameDetailsJSON)" << std::endl << json << std::endl;
|
||||||
#endif
|
|
||||||
std::cout << exc.what();
|
std::cout << exc.what();
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
std::cerr << "DEBUG INFO (Website::getGameDetailsJSON)" << std::endl << root << std::endl;
|
std::cerr << "DEBUG INFO (Website::getGameDetailsJSON)" << std::endl << root << std::endl;
|
||||||
#endif
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@ -113,9 +113,9 @@ std::vector<gameItem> Website::getGames()
|
|||||||
// Parse JSON
|
// Parse JSON
|
||||||
json_stream >> root;
|
json_stream >> root;
|
||||||
} catch (const Json::Exception& exc) {
|
} catch (const Json::Exception& exc) {
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
std::cerr << "DEBUG INFO (Website::getGames)" << std::endl << response << std::endl;
|
std::cerr << "DEBUG INFO (Website::getGames)" << std::endl << response << std::endl;
|
||||||
#endif
|
|
||||||
std::cout << exc.what();
|
std::cout << exc.what();
|
||||||
if (!response.empty())
|
if (!response.empty())
|
||||||
{
|
{
|
||||||
@ -127,9 +127,9 @@ std::vector<gameItem> Website::getGames()
|
|||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
std::cerr << "DEBUG INFO (Website::getGames)" << std::endl << root << std::endl;
|
std::cerr << "DEBUG INFO (Website::getGames)" << std::endl << root << std::endl;
|
||||||
#endif
|
|
||||||
if (root["page"].asInt() == root["totalPages"].asInt() || root["totalPages"].asInt() == 0)
|
if (root["page"].asInt() == root["totalPages"].asInt() || root["totalPages"].asInt() == 0)
|
||||||
bAllPagesParsed = true;
|
bAllPagesParsed = true;
|
||||||
|
|
||||||
@ -280,10 +280,12 @@ int Website::Login(const std::string& email, const std::string& password)
|
|||||||
bool bRecaptcha = false;
|
bool bRecaptcha = false;
|
||||||
|
|
||||||
std::string login_form_html = this->getResponse(auth_url);
|
std::string login_form_html = this->getResponse(auth_url);
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
|
{
|
||||||
std::cerr << "DEBUG INFO (Website::Login)" << std::endl;
|
std::cerr << "DEBUG INFO (Website::Login)" << std::endl;
|
||||||
std::cerr << login_form_html << std::endl;
|
std::cerr << login_form_html << std::endl;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (login_form_html.find("class=\"g-recaptcha form__recaptcha\"") != std::string::npos)
|
if (login_form_html.find("class=\"g-recaptcha form__recaptcha\"") != std::string::npos)
|
||||||
{
|
{
|
||||||
bRecaptcha = true;
|
bRecaptcha = true;
|
||||||
@ -601,15 +603,15 @@ std::vector<wishlistItem> Website::getWishlistItems()
|
|||||||
// Parse JSON
|
// Parse JSON
|
||||||
response_stream >> root;
|
response_stream >> root;
|
||||||
} catch(const Json::Exception& exc) {
|
} catch(const Json::Exception& exc) {
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
std::cerr << "DEBUG INFO (Website::getWishlistItems)" << std::endl << response << std::endl;
|
std::cerr << "DEBUG INFO (Website::getWishlistItems)" << std::endl << response << std::endl;
|
||||||
#endif
|
|
||||||
std::cout << exc.what();
|
std::cout << exc.what();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
if (Globals::globalConfig.iMsgLevel >= MSGLEVEL_DEBUG)
|
||||||
std::cerr << "DEBUG INFO (Website::getWishlistItems)" << std::endl << root << std::endl;
|
std::cerr << "DEBUG INFO (Website::getWishlistItems)" << std::endl << root << std::endl;
|
||||||
#endif
|
|
||||||
if (root["page"].asInt() >= root["totalPages"].asInt())
|
if (root["page"].asInt() >= root["totalPages"].asInt())
|
||||||
bAllPagesParsed = true;
|
bAllPagesParsed = true;
|
||||||
if (root["products"].isArray())
|
if (root["products"].isArray())
|
||||||
|
Loading…
Reference in New Issue
Block a user