|
@@ -29,12 +29,12 @@ void PatchDownloader::startPatchDownloaderChain() {
|
|
if (started_) {
|
|
if (started_) {
|
|
qCritical() << "PatchDwnlder: Tried to start patch downloader chain while other was already running!";
|
|
qCritical() << "PatchDwnlder: Tried to start patch downloader chain while other was already running!";
|
|
}
|
|
}
|
|
- started_ = true;
|
|
|
|
emit started();
|
|
emit started();
|
|
|
|
+ started_ = true;
|
|
checkForUpdates();
|
|
checkForUpdates();
|
|
- beginDownload();
|
|
|
|
- // Finished signal will be emitted when all downloads are completed.
|
|
|
|
- // Note, this function finishes immediately after downloads are STARTED!
|
|
|
|
|
|
+ downloadDatabases();
|
|
|
|
+ started_ = false;
|
|
|
|
+ emit finished();
|
|
}
|
|
}
|
|
|
|
|
|
void PatchDownloader::onDownloaderProgressChanged(Downloader* context, Downloader::Status progress) {
|
|
void PatchDownloader::onDownloaderProgressChanged(Downloader* context, Downloader::Status progress) {
|
|
@@ -52,17 +52,6 @@ void PatchDownloader::onDownloaderFinished(Downloader* context) {
|
|
context->targetFile->deleteLater();
|
|
context->targetFile->deleteLater();
|
|
context->targetFile = nullptr;
|
|
context->targetFile = nullptr;
|
|
Settings::setValue("DatabaseNeedInstall/" + patch_downloaders_.key(context), true);
|
|
Settings::setValue("DatabaseNeedInstall/" + patch_downloaders_.key(context), true);
|
|
-
|
|
|
|
- patch_downloaders_status_[context] = context->getDownloadStatus();
|
|
|
|
- Downloader::Status cumulative_status;
|
|
|
|
- for (const Downloader::Status& status: patch_downloaders_status_.values()) {
|
|
|
|
- cumulative_status = cumulative_status + status;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!cumulative_status.running) {
|
|
|
|
- started_ = false;
|
|
|
|
- emit finished();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void PatchDownloader::checkForUpdates() {
|
|
void PatchDownloader::checkForUpdates() {
|
|
@@ -113,9 +102,7 @@ void PatchDownloader::checkForUpdates() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void PatchDownloader::beginDownload() {
|
|
|
|
- bool downloads_started = false;
|
|
|
|
-
|
|
|
|
|
|
+void PatchDownloader::downloadDatabases() {
|
|
for (const QString& patch: patches_) {
|
|
for (const QString& patch: patches_) {
|
|
QString target_filename = Settings::getValue("PatchDatabases/" + patch + "/path").toString();
|
|
QString target_filename = Settings::getValue("PatchDatabases/" + patch + "/path").toString();
|
|
|
|
|
|
@@ -137,17 +124,14 @@ void PatchDownloader::beginDownload() {
|
|
patch_downloaders_[patch]->setUrl(Settings::getValue("PatchDatabases/" + patch + "/url").toUrl());
|
|
patch_downloaders_[patch]->setUrl(Settings::getValue("PatchDatabases/" + patch + "/url").toUrl());
|
|
patch_downloaders_[patch]->targetFile = target_file;
|
|
patch_downloaders_[patch]->targetFile = target_file;
|
|
patch_downloaders_[patch]->start();
|
|
patch_downloaders_[patch]->start();
|
|
- downloads_started = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if (!downloads_started) {
|
|
|
|
- started_ = false;
|
|
|
|
- emit finished();
|
|
|
|
|
|
+ for (Downloader* patch_downloader: patch_downloaders_) {
|
|
|
|
+ patch_downloader->waitForDownloaded();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
bool PatchDownloader::needDownloadDatabase(QString db_name)
|
|
bool PatchDownloader::needDownloadDatabase(QString db_name)
|
|
{
|
|
{
|
|
QString patch_filename = Settings::getValue("PatchDatabases/" + db_name + "/path").toString();
|
|
QString patch_filename = Settings::getValue("PatchDatabases/" + db_name + "/path").toString();
|