[Pkg-owncloud-commits] [owncloud-client] 97/470: Checksums: Content checksums for all uploads #4375
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:24:49 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 7ed7512f272caac5ad7668087259a46ed2873401
Author: Christian Kamm <mail at ckamm.de>
Date: Wed Mar 2 13:52:14 2016 +0100
Checksums: Content checksums for all uploads #4375
---
src/libsync/checksums.cpp | 9 +++++++++
src/libsync/checksums.h | 4 ++++
src/libsync/propagateupload.cpp | 13 ++++---------
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/libsync/checksums.cpp b/src/libsync/checksums.cpp
index 1e4e295..99101fd 100644
--- a/src/libsync/checksums.cpp
+++ b/src/libsync/checksums.cpp
@@ -114,6 +114,15 @@ bool downloadChecksumEnabled()
return enabled;
}
+QByteArray contentChecksumType()
+{
+ static QByteArray type = qgetenv("OWNCLOUD_CONTENT_CHECKSUM_TYPE");
+ if (!type.isNull()) { // can set to "" to disable checksumming
+ return type;
+ }
+ return "SHA1";
+}
+
ComputeChecksum::ComputeChecksum(QObject* parent)
: QObject(parent)
{
diff --git a/src/libsync/checksums.h b/src/libsync/checksums.h
index 30a0403..519c74b 100644
--- a/src/libsync/checksums.h
+++ b/src/libsync/checksums.h
@@ -37,6 +37,10 @@ bool uploadChecksumEnabled();
/// Checks OWNCLOUD_DISABLE_CHECKSUM_DOWNLOAD
bool downloadChecksumEnabled();
+/// Checks OWNCLOUD_CONTENT_CHECKSUM_TYPE (default: SHA1)
+QByteArray contentChecksumType();
+
+
/**
* Computes the checksum of a file.
* \ingroup libsync
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index 1d76434..896cd41 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -219,23 +219,18 @@ void PropagateUploadFileQNAM::slotComputeContentChecksum()
_stopWatch.start();
- QByteArray contentChecksumType;
- // We currently only do content checksums for the particular .eml case
- // This should be done more generally in the future!
- if (filePath.endsWith(QLatin1String(".eml"), Qt::CaseInsensitive)) {
- contentChecksumType = "MD5";
- }
+ QByteArray checksumType = contentChecksumType();
// Maybe the discovery already computed the checksum?
- if (_item->_contentChecksumType == contentChecksumType
+ if (_item->_contentChecksumType == checksumType
&& !_item->_contentChecksum.isEmpty()) {
- slotComputeTransmissionChecksum(contentChecksumType, _item->_contentChecksum);
+ slotComputeTransmissionChecksum(checksumType, _item->_contentChecksum);
return;
}
// Compute the content checksum.
auto computeChecksum = new ComputeChecksum(this);
- computeChecksum->setChecksumType(contentChecksumType);
+ computeChecksum->setChecksumType(checksumType);
connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray)));
--
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