[Pkg-owncloud-commits] [owncloud-client] 65/175: Propagate Download: Handle malformed checksum header as error.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:27 UTC 2015


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 8b371c42b766edb31fcb0f17bf9a939ad54d6e15
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue May 19 16:49:22 2015 +0200

    Propagate Download: Handle malformed checksum header as error.
    
    Plus some cleanup, bool ok was not needed actually.
---
 src/libsync/transmissionchecksumvalidator.cpp | 41 +++++++++++++--------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/src/libsync/transmissionchecksumvalidator.cpp b/src/libsync/transmissionchecksumvalidator.cpp
index e6fd6f3..a9af205 100644
--- a/src/libsync/transmissionchecksumvalidator.cpp
+++ b/src/libsync/transmissionchecksumvalidator.cpp
@@ -103,36 +103,33 @@ void TransmissionChecksumValidator::downloadValidation( const QByteArray& checks
         return;
     }
 
-    bool ok = true;
-
     int indx = checksumHeader.indexOf(':');
     if( indx < 0 ) {
         qDebug() << "Checksum header malformed:" << checksumHeader;
-        emit validated(); // show must go on - even not validated.
+        emit validationFailed(tr("The checksum header is malformed.")); // show must go on - even not validated.
+        return;
     }
 
-    if( ok ) {
-        const QByteArray type = checksumHeader.left(indx).toUpper();
-        _expectedHash = checksumHeader.mid(indx+1);
+    const QByteArray type = checksumHeader.left(indx).toUpper();
+    _expectedHash = checksumHeader.mid(indx+1);
 
-        connect( &_watcher, SIGNAL(finished()), this, SLOT(slotDownloadChecksumCalculated()) );
+    connect( &_watcher, SIGNAL(finished()), this, SLOT(slotDownloadChecksumCalculated()) );
 
-        // start the calculation in different thread
-        if( type == checkSumMD5C ) {
-            _watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5Worker, _filePath));
-        } else if( type == checkSumSHA1C ) {
-            _watcher.setFuture(QtConcurrent::run(FileSystem::calcSha1Worker, _filePath));
-        }
+    // start the calculation in different thread
+    if( type == checkSumMD5C ) {
+        _watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5Worker, _filePath));
+    } else if( type == checkSumSHA1C ) {
+        _watcher.setFuture(QtConcurrent::run(FileSystem::calcSha1Worker, _filePath));
+    }
 #ifdef ZLIB_FOUND
-        else if( type == checkSumAdlerUpperC ) {
-            _watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32Worker, _filePath));
-        }
+    else if( type == checkSumAdlerUpperC ) {
+        _watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32Worker, _filePath));
+    }
 #endif
-        else {
-            qDebug() << "Unknown checksum type" << type;
-            emit validationFailed(tr("The checksum header was malformed."));
-            return;
-        }
+    else {
+        qDebug() << "Unknown checksum type" << type;
+        emit validationFailed(tr("The checksum header is malformed."));
+        return;
     }
 }
 
@@ -141,7 +138,7 @@ void TransmissionChecksumValidator::slotDownloadChecksumCalculated()
     const QByteArray hash = _watcher.future().result();
 
     if( hash != _expectedHash ) {
-        emit validationFailed(tr("The file downloaded with a broken checksum, will be redownloaded."));
+        emit validationFailed(tr("The downloaded file does not match the checksum, it will be resumed."));
     } else {
         qDebug() << "Checksum checked and matching: " << _expectedHash;
         emit validated();

-- 
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