[Pkg-owncloud-commits] [owncloud-client] 25/78: Checksums: Compute content checksum on download #4375
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Jun 24 16:29:39 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 9aed8dbce85beaceef27348ff62882fb249a49a8
Author: Christian Kamm <mail at ckamm.de>
Date: Wed Mar 2 14:20:36 2016 +0100
Checksums: Compute content checksum on download #4375
Cherry-picked from d6d35029
---
src/libsync/propagatedownload.cpp | 33 +++++++++++++++++++++++++++++++--
src/libsync/propagatedownload.h | 2 ++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 0dd9205..f3cce6b 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -552,11 +552,11 @@ void PropagateDownloadFileQNAM::slotGetFinished()
}
// Do checksum validation for the download. If there is no checksum header, the validator
- // will also emit the validated() signal to continue the flow in slot downloadFinished()
+ // will also emit the validated() signal to continue the flow in slot transmissionChecksumValidated()
// as this is (still) also correct.
ValidateChecksumHeader *validator = new ValidateChecksumHeader(this);
connect(validator, SIGNAL(validated(QByteArray,QByteArray)),
- SLOT(downloadFinished()));
+ SLOT(transmissionChecksumValidated(QByteArray,QByteArray)));
connect(validator, SIGNAL(validationFailed(QString)),
SLOT(slotChecksumFail(QString)));
auto checksumHeader = job->reply()->rawHeader(checkSumHeaderC);
@@ -644,6 +644,35 @@ static void handleRecallFile(const QString &fn)
}
} // end namespace
+void PropagateDownloadFileQNAM::transmissionChecksumValidated(const QByteArray &checksumType, const QByteArray &checksum)
+{
+ const auto theContentChecksumType = QByteArray("SHA1");
+
+ // Reuse transmission checksum as content checksum.
+ //
+ // We could do this more aggressively and accept both MD5 and SHA1
+ // instead of insisting on the exactly correct checksum type.
+ if (theContentChecksumType == checksumType || theContentChecksumType.isEmpty()) {
+ return contentChecksumComputed(checksumType, checksum);
+ }
+
+ // Compute the content checksum.
+ auto computeChecksum = new ComputeChecksum(this);
+ computeChecksum->setChecksumType(theContentChecksumType);
+
+ connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
+ SLOT(contentChecksumComputed(QByteArray,QByteArray)));
+ computeChecksum->start(_tmpFile.fileName());
+}
+
+void PropagateDownloadFileQNAM::contentChecksumComputed(const QByteArray &checksumType, const QByteArray &checksum)
+{
+ _item->_contentChecksum = checksum;
+ _item->_contentChecksumType = checksumType;
+
+ downloadFinished();
+}
+
void PropagateDownloadFileQNAM::downloadFinished()
{
QString fn = _propagator->getFilePath(_item->_file);
diff --git a/src/libsync/propagatedownload.h b/src/libsync/propagatedownload.h
index 8ba11f1..32829fa 100644
--- a/src/libsync/propagatedownload.h
+++ b/src/libsync/propagatedownload.h
@@ -128,6 +128,8 @@ public:
private slots:
void slotGetFinished();
void abort() Q_DECL_OVERRIDE;
+ void transmissionChecksumValidated(const QByteArray& checksumType, const QByteArray& checksum);
+ void contentChecksumComputed(const QByteArray& checksumType, const QByteArray& checksum);
void downloadFinished();
void slotDownloadProgress(qint64,qint64);
void slotChecksumFail( const QString& errMsg );
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list