diff --git a/src/common/checksums.cpp b/src/common/checksums.cpp index 245bcaa37..278277c1e 100644 --- a/src/common/checksums.cpp +++ b/src/common/checksums.cpp @@ -133,6 +133,12 @@ QByteArray contentChecksumType() return type; } +static bool checksumComputationEnabled() +{ + static bool enabled = qgetenv("OWNCLOUD_DISABLE_CHECKSUM_COMPUTATIONS").isEmpty(); + return enabled; +} + ComputeChecksum::ComputeChecksum(QObject *parent) : QObject(parent) { @@ -150,6 +156,8 @@ QByteArray ComputeChecksum::checksumType() const void ComputeChecksum::start(const QString &filePath) { + qCInfo(lcChecksums) << "Computing" << checksumType() << "checksum of" << filePath << "in a thread"; + // Calculate the checksum in a different thread first. connect(&_watcher, &QFutureWatcherBase::finished, this, &ComputeChecksum::slotCalculationDone, @@ -159,6 +167,11 @@ void ComputeChecksum::start(const QString &filePath) QByteArray ComputeChecksum::computeNow(const QString &filePath, const QByteArray &checksumType) { + if (!checksumComputationEnabled()) { + qCWarning(lcChecksums) << "Checksum computation disabled by environment variable"; + return QByteArray(); + } + if (checksumType == checkSumMD5C) { return FileSystem::calcMd5(filePath); } else if (checksumType == checkSumSHA1C) { @@ -237,6 +250,7 @@ QByteArray CSyncChecksumHook::hook(const QByteArray &path, const QByteArray &oth if (type.isEmpty()) return NULL; + qCInfo(lcChecksums) << "Computing" << type << "checksum of" << path << "in the csync hook"; QByteArray checksum = ComputeChecksum::computeNow(QString::fromUtf8(path), type); if (checksum.isNull()) { qCWarning(lcChecksums) << "Failed to compute checksum" << type << "for" << path;