Propagate: On download store checksum header in db #3735
authorChristian Kamm <mail@ckamm.de>
Wed, 14 Oct 2015 13:29:27 +0000 (15:29 +0200)
committerChristian Kamm <mail@ckamm.de>
Wed, 28 Oct 2015 08:56:39 +0000 (09:56 +0100)
src/libsync/propagatedownload.cpp
src/libsync/propagatedownload.h

index b37e6bd8844ad351ad2e91faadde5014080acb69..5fd94da6695f126693c576ccba0163a86dcfeb69 100644 (file)
@@ -351,7 +351,10 @@ void PropagateDownloadFileQNAM::start()
         if (_resumeStart == _item->_size) {
             qDebug() << "File is already complete, no need to download";
             _tmpFile.close();
-            downloadFinished();
+
+            // Unfortunately we lost the checksum header, if any...
+            QByteArray checksumHeader;
+            downloadFinished(checksumHeader);
             return;
         }
     }
@@ -532,7 +535,7 @@ void PropagateDownloadFileQNAM::slotGetFinished()
     // will also emit the validated() signal to continue the flow in slot downloadFinished()
     // as this is (still) also correct.
     ValidateChecksumHeader *validator = new ValidateChecksumHeader(this);
-    connect(validator, SIGNAL(validated(QByteArray)), this, SLOT(downloadFinished()));
+    connect(validator, SIGNAL(validated(QByteArray)), this, SLOT(downloadFinished(QByteArray)));
     connect(validator, SIGNAL(validationFailed(QString)), this, SLOT(slotChecksumFail(QString)));
     validator->start(_tmpFile.fileName(), job->reply()->rawHeader(checkSumHeaderC));
 }
@@ -611,8 +614,12 @@ static void handleRecallFile(const QString &fn)
 }
 } // end namespace
 
-void PropagateDownloadFileQNAM::downloadFinished()
+void PropagateDownloadFileQNAM::downloadFinished(const QByteArray& checksumHeader)
 {
+    if (!checksumHeader.isEmpty()) {
+        _item->_checksumHeader = checksumHeader;
+    }
+
     QString fn = _propagator->getFilePath(_item->_file);
 
     // In case of file name clash, report an error
index 32e05db28ae457bced321121db0449f33f55794b..9a5c2b326fbdcfda00085ae37f6444538d0f339b 100644 (file)
@@ -117,7 +117,7 @@ public:
 private slots:
     void slotGetFinished();
     void abort() Q_DECL_OVERRIDE;
-    void downloadFinished();
+    void downloadFinished(const QByteArray& checksumHeader);
     void slotDownloadProgress(qint64,qint64);
     void slotChecksumFail( const QString& errMsg );