__FORCE_ALIGN_STACK__ int Download(int ID, const std::string& filename, DownloadEnum::Category cat) { currentDownloadID = ID; // FIXME: Progress is incorrectly updated when rapid is queried to check for existing packages. SetDownloadListener(UpdateProgress); LOG_L(L_DEBUG, "Going to download %s", filename.c_str()); DownloadInit(); const int count = DownloadSearch(cat, filename.c_str()); for (int i = 0; i < count; i++) { DownloadAdd(i); struct downloadInfo dl; if (DownloadGetInfo(i, dl)) { LOG_L(L_DEBUG, "Download info: %s %d", dl.filename, dl.cat); } } int result; LOG_L(L_DEBUG, "Download count: %d", count); // TODO: count will be 1 when archives already exist. We should instead return a different result with DownloadFailed/DownloadFinished? if (count == 0) { // there's nothing to download result = 2; QueueDownloadFailed(ID, result); } else { QueueDownloadStarted(ID); result = DownloadStart(); LOG_L(L_DEBUG, "Download finished %s", filename.c_str()); } DownloadShutdown(); return result; }
__FORCE_ALIGN_STACK__ int Download(int ID, const std::string& filename, DownloadEnum::Category cat) { currentDownloadID = ID; // FIXME: Progress is incorrectly updated when rapid is queried to check for existing packages. SetDownloadListener(UpdateProgress); LOG_L(L_DEBUG, "Going to download %s", filename.c_str()); DownloadInit(); const int count = DownloadSearch(cat, filename.c_str()); for (int i = 0; i < count; i++) { DownloadAdd(i); struct downloadInfo dl; if (DownloadGetInfo(i, dl)) { LOG_L(L_DEBUG, "Download info: %s %d", dl.filename, dl.cat); } } int result; LOG_L(L_DEBUG, "Download count: %d", count); // TODO: count will be 1 when archives already exist. We should instead return a different result with DownloadFailed/DownloadFinished? if (count == 0) { // there's nothing to download result = 2; QueueDownloadFailed(ID, result); } else { LOG_L(L_DEBUG, "Download finished %s", filename.c_str()); QueueDownloadStarted(ID); result = DownloadStart(); // TODO: This works but there are errors spammed as it's trying to clear timers in the main thread, which this is not: // Error: [Watchdog::ClearTimer(id)] Invalid thread 4 (_threadId=(nil)) archiveScanner->ScanAllDirs(); } DownloadShutdown(); return result; }