From d60846a3ec4caaf7e8207cb36c120554a8507b0b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 23 Jun 2015 00:36:31 +0200 Subject: [PATCH] Made destination optional in data specifications --- apps/Launcher/syncwidget.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/apps/Launcher/syncwidget.cpp b/apps/Launcher/syncwidget.cpp index 047ac456de..7f6540f696 100644 --- a/apps/Launcher/syncwidget.cpp +++ b/apps/Launcher/syncwidget.cpp @@ -312,16 +312,15 @@ void SyncWidget::syncButtonPressed() { continue; } ghoul::Dictionary d = directDownloadFiles.value(std::to_string(i)); - if (!directDownloadFiles.hasKeyAndValue(UrlKey)) { + if (!d.hasKeyAndValue(UrlKey)) { LERROR(dataFile.toStdString() << ": No " << UrlKey); continue; } std::string url = d.value(UrlKey); - if (!directDownloadFiles.hasKeyAndValue(DestinationKey)) { - LERROR(dataFile.toStdString() << ": No " << DestinationKey); - continue; - } - std::string dest = d.value(DestinationKey); + + std::string dest = ""; + if (d.hasKeyAndValue(DestinationKey)) + dest = d.value(DestinationKey); _directFiles.append({ module, @@ -335,10 +334,22 @@ void SyncWidget::syncButtonPressed() { if (found) { for (int i = 1; i <= fileRequests.size(); ++i) { ghoul::Dictionary d = fileRequests.value(std::to_string(i)); - std::string url = d.value(IdentifierKey); - std::string dest = d.value(DestinationKey); - int version = static_cast(d.value(VersionKey)); + if (!d.hasKeyAndValue(IdentifierKey)) { + LERROR(dataFile.toStdString() << ": No " << IdentifierKey); + continue; + } + std::string url = d.value(IdentifierKey); + + std::string dest = ""; + if (d.hasKeyAndValue(DestinationKey)) + dest = d.value(DestinationKey); + + if (!d.hasKeyAndValue(VersionKey)) { + LERROR(dataFile.toStdString() << ": No " << VersionKey); + continue; + } + int version = static_cast(d.value(VersionKey)); _fileRequests.append({ module, @@ -353,6 +364,11 @@ void SyncWidget::syncButtonPressed() { if (found) { for (int i = 1; i <= torrentFiles.size(); ++i) { ghoul::Dictionary d = torrentFiles.value(std::to_string(i)); + + if (!d.hasKeyAndValue(FileKey)) { + LERROR(dataFile.toStdString() << ": No " << FileKey); + continue; + } std::string file = d.value(FileKey); std::string dest;