[Pkg-owncloud-commits] [owncloud-client] 173/484: Checksum: Fix recomputation when forced in cfg file #3735

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:40 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 b9fc4c5994d86924eb287908d038ffcf8358b0ec
Author: Christian Kamm <mail at ckamm.de>
Date:   Thu Oct 15 09:54:01 2015 +0200

    Checksum: Fix recomputation when forced in cfg file #3735
    
    Don't recompute the checksum on each upload when the server does not
    advertise supporting checksums.
---
 src/libsync/capabilities.cpp                  | 23 ++++++++++++++++++++++-
 src/libsync/capabilities.h                    |  8 ++++++++
 src/libsync/propagateupload.cpp               | 14 +++-----------
 src/libsync/transmissionchecksumvalidator.cpp |  4 ----
 src/libsync/transmissionchecksumvalidator.h   |  3 +--
 5 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp
index c6887c8..81f8d98 100644
--- a/src/libsync/capabilities.cpp
+++ b/src/libsync/capabilities.cpp
@@ -13,6 +13,8 @@
 
 #include "capabilities.h"
 
+#include "configfile.h"
+
 #include <QVariantMap>
 
 namespace OCC {
@@ -63,9 +65,28 @@ bool Capabilities::shareResharing() const
     return _capabilities["files_sharing"].toMap()["resharing"].toBool();
 }
 
-QList<QByteArray> Capabilities::supportedChecksumTypes() const
+QList<QByteArray> Capabilities::supportedChecksumTypesRaw() const
 {
     return QList<QByteArray>();
 }
 
+QList<QByteArray> Capabilities::supportedChecksumTypes() const
+{
+    auto list = supportedChecksumTypesRaw();
+    QByteArray cfgType = ConfigFile().transmissionChecksum().toLatin1();
+    if (!cfgType.isEmpty()) {
+        list.prepend(cfgType);
+    }
+    return list;
+}
+
+QByteArray Capabilities::preferredChecksumType() const
+{
+    auto list = supportedChecksumTypes();
+    if (list.isEmpty()) {
+        return QByteArray();
+    }
+    return list.first();
+}
+
 }
diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h
index 28bcca6..7f0984c 100644
--- a/src/libsync/capabilities.h
+++ b/src/libsync/capabilities.h
@@ -39,8 +39,16 @@ public:
     bool sharePublicLinkEnforceExpireDate() const;
     int  sharePublicLinkExpireDateDays() const;
     bool shareResharing() const;
+
+    /// Returns the checksum types the server explicitly advertises
+    QList<QByteArray> supportedChecksumTypesRaw() const;
+
+    /// Like supportedChecksumTypesRaw(), but includes the type from the config
     QList<QByteArray> supportedChecksumTypes() const;
 
+    /// Returns the checksum type that should be used for new uploads.
+    QByteArray preferredChecksumType() const;
+
 private:
     QVariantMap _capabilities;
 };
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index a745d46..3412c0e 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -227,17 +227,9 @@ void PropagateUploadFileQNAM::start()
 
     // Compute a new checksum.
     auto computeChecksum = new ComputeChecksum(this);
-
-    // If the config file does not specify a checksum type but the
-    // server supports it, choose a type based on that.
-    if (computeChecksum->checksumType().isEmpty()) {
-        if (!supportedChecksumTypes.isEmpty()) {
-            // TODO: We might want to prefer some types over others instead
-            // of choosing the first.
-            computeChecksum->setChecksumType(supportedChecksumTypes.first());
-        }
-    }
-    if (!uploadChecksumEnabled()) {
+    if (uploadChecksumEnabled()) {
+        computeChecksum->setChecksumType(_propagator->account()->capabilities().preferredChecksumType());
+    } else {
         computeChecksum->setChecksumType(QByteArray());
     }
 
diff --git a/src/libsync/transmissionchecksumvalidator.cpp b/src/libsync/transmissionchecksumvalidator.cpp
index 21653fc..1a0caaf 100644
--- a/src/libsync/transmissionchecksumvalidator.cpp
+++ b/src/libsync/transmissionchecksumvalidator.cpp
@@ -16,7 +16,6 @@
 #include "transmissionchecksumvalidator.h"
 #include "syncfileitem.h"
 #include "propagatorjobs.h"
-#include "configfile.h"
 #include "account.h"
 
 #include <qtconcurrentrun.h>
@@ -64,9 +63,6 @@ bool downloadChecksumEnabled()
 ComputeChecksum::ComputeChecksum(QObject* parent)
     : QObject(parent)
 {
-    // If the config file specifies a checksum type, use that.
-    ConfigFile cfg;
-    _checksumType = cfg.transmissionChecksum().toLatin1();
 }
 
 void ComputeChecksum::setChecksumType(const QByteArray& type)
diff --git a/src/libsync/transmissionchecksumvalidator.h b/src/libsync/transmissionchecksumvalidator.h
index b8f1022..9ae1a11 100644
--- a/src/libsync/transmissionchecksumvalidator.h
+++ b/src/libsync/transmissionchecksumvalidator.h
@@ -46,8 +46,7 @@ public:
     explicit ComputeChecksum(QObject* parent = 0);
 
     /**
-     * By default the checksum type is read from the config file, but can be overridden
-     * with this method.
+     * Sets the checksum type to be used. The default is empty.
      */
     void setChecksumType(const QByteArray& type);
 

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