From: Hannah von Reth Date: Fri, 24 Jul 2020 15:16:28 +0000 (+0200) Subject: Use the servers checksum type by default X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~77 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c1a91e91e7dabf0998833902ac914ae8c8e2b428;p=nextcloud-desktop.git Use the servers checksum type by default --- diff --git a/src/common/checksums.cpp b/src/common/checksums.cpp index 462e2d3e5..aef426813 100644 --- a/src/common/checksums.cpp +++ b/src/common/checksums.cpp @@ -189,15 +189,6 @@ bool uploadChecksumEnabled() return enabled; } -QByteArray contentChecksumType() -{ - static QByteArray type = qgetenv("OWNCLOUD_CONTENT_CHECKSUM_TYPE"); - if (type.isNull()) { // can set to "" to disable checksumming - type = "SHA1"; - } - return type; -} - static bool checksumComputationEnabled() { static bool enabled = qEnvironmentVariableIsEmpty("OWNCLOUD_DISABLE_CHECKSUM_COMPUTATIONS"); diff --git a/src/common/checksums.h b/src/common/checksums.h index 1e5151c7a..5c8d39d5c 100644 --- a/src/common/checksums.h +++ b/src/common/checksums.h @@ -65,9 +65,6 @@ OCSYNC_EXPORT QByteArray parseChecksumHeaderType(const QByteArray &header); /// Checks OWNCLOUD_DISABLE_CHECKSUM_UPLOAD OCSYNC_EXPORT bool uploadChecksumEnabled(); -/// Checks OWNCLOUD_CONTENT_CHECKSUM_TYPE (default: SHA1) -OCSYNC_EXPORT QByteArray contentChecksumType(); - // Exported functions for the tests. QByteArray OCSYNC_EXPORT calcMd5(QIODevice *device); QByteArray OCSYNC_EXPORT calcSha1(QIODevice *device); diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index 1ea4a58dc..04600601d 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -150,7 +150,9 @@ QList Capabilities::supportedChecksumTypes() const QByteArray Capabilities::preferredUploadChecksumType() const { - return _capabilities["checksums"].toMap()["preferredUploadType"].toByteArray(); + return qEnvironmentVariable("OWNCLOUD_CONTENT_CHECKSUM_TYPE", + _capabilities.value(QStringLiteral("checksums")).toMap() + .value(QStringLiteral("preferredUploadType"), QStringLiteral("SHA1")).toString()).toUtf8(); } QByteArray Capabilities::uploadChecksumType() const diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index b630778c8..99ee0fe05 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -909,7 +909,7 @@ namespace { // Anonymous namespace for the recall feature void PropagateDownloadFile::transmissionChecksumValidated(const QByteArray &checksumType, const QByteArray &checksum) { - const auto theContentChecksumType = contentChecksumType(); + const QByteArray theContentChecksumType = propagator()->account()->capabilities().preferredUploadChecksumType(); // Reuse transmission checksum as content checksum. // diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index 14c6416d3..f64ef03a3 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -349,7 +349,7 @@ void PropagateUploadFileCommon::slotComputeContentChecksum() // probably temporary one. _item->_modtime = FileSystem::getModTime(filePath); - QByteArray checksumType = contentChecksumType(); + const QByteArray checksumType = propagator()->account()->capabilities().preferredUploadChecksumType(); // Maybe the discovery already computed the checksum? // Should I compute the checksum of the original (_item->_file)