Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/checksums.cpp7
-rw-r--r--src/common/checksums.h4
-rw-r--r--src/libsync/configfile.cpp6
-rw-r--r--src/libsync/configfile.h3
-rw-r--r--src/libsync/propagatedownload.cpp61
-rw-r--r--src/libsync/propagatedownload.h4
-rw-r--r--test/testchecksumvalidator.cpp3
7 files changed, 15 insertions, 73 deletions
diff --git a/src/common/checksums.cpp b/src/common/checksums.cpp
index 79038554f..c604842a3 100644
--- a/src/common/checksums.cpp
+++ b/src/common/checksums.cpp
@@ -328,7 +328,7 @@ ComputeChecksum *ValidateChecksumHeader::prepareStart(const QByteArray &checksum
if (!parseChecksumHeader(checksumHeader, &_expectedChecksumType, &_expectedChecksum)) {
qCWarning(lcChecksums) << "Checksum header malformed:" << checksumHeader;
- emit validationFailed(tr("The checksum header is malformed."), {}, {}, _filePath);
+ emit validationFailed(tr("The checksum header is malformed."));
return nullptr;
}
@@ -341,7 +341,6 @@ ComputeChecksum *ValidateChecksumHeader::prepareStart(const QByteArray &checksum
void ValidateChecksumHeader::start(const QString &filePath, const QByteArray &checksumHeader)
{
- _filePath = filePath;
if (auto calculator = prepareStart(checksumHeader))
calculator->start(filePath);
}
@@ -356,11 +355,11 @@ void ValidateChecksumHeader::slotChecksumCalculated(const QByteArray &checksumTy
const QByteArray &checksum)
{
if (checksumType != _expectedChecksumType) {
- emit validationFailed(tr("The checksum header contained an unknown checksum type '%1'").arg(QString::fromLatin1(_expectedChecksumType)), {}, {}, _filePath);
+ emit validationFailed(tr("The checksum header contained an unknown checksum type '%1'").arg(QString::fromLatin1(_expectedChecksumType)));
return;
}
if (checksum != _expectedChecksum) {
- emit validationFailed(tr("The downloaded file does not match the checksum, it will be resumed. '%1' != '%2'").arg(QString::fromUtf8(_expectedChecksum), QString::fromUtf8(checksum)), checksumType, checksum, _filePath);
+ emit validationFailed(tr("The downloaded file does not match the checksum, it will be resumed. '%1' != '%2'").arg(QString::fromUtf8(_expectedChecksum), QString::fromUtf8(checksum)));
return;
}
emit validated(checksumType, checksum);
diff --git a/src/common/checksums.h b/src/common/checksums.h
index 843017a43..5c8d39d5c 100644
--- a/src/common/checksums.h
+++ b/src/common/checksums.h
@@ -163,7 +163,7 @@ public:
signals:
void validated(const QByteArray &checksumType, const QByteArray &checksum);
- void validationFailed(const QString &errMsg, const QByteArray &checksumType, const QByteArray &checksum, const QString &filePath);
+ void validationFailed(const QString &errMsg);
private slots:
void slotChecksumCalculated(const QByteArray &checksumType, const QByteArray &checksum);
@@ -173,8 +173,6 @@ private:
QByteArray _expectedChecksumType;
QByteArray _expectedChecksum;
-
- QString _filePath;
};
/**
diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp
index 24986f3cb..ba5092729 100644
--- a/src/libsync/configfile.cpp
+++ b/src/libsync/configfile.cpp
@@ -50,7 +50,6 @@
#define DEFAULT_MAX_LOG_LINES 20000
namespace {
-static constexpr char allowChecksumValidationFailC[] = "allowChecksumValidationFail";
static constexpr char showMainDialogAsNormalWindowC[] = "showMainDialogAsNormalWindow";
}
@@ -892,11 +891,6 @@ void ConfigFile::setMoveToTrash(bool isChecked)
setValue(moveToTrashC, isChecked);
}
-bool ConfigFile::allowChecksumValidationFail() const
-{
- return getValue(allowChecksumValidationFailC, {}, false).toBool();
-}
-
bool ConfigFile::showMainDialogAsNormalWindow() const {
return getValue(showMainDialogAsNormalWindowC, {}, false).toBool();
}
diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h
index 5f288bede..fb52c02c9 100644
--- a/src/libsync/configfile.h
+++ b/src/libsync/configfile.h
@@ -145,9 +145,6 @@ public:
bool moveToTrash() const;
void setMoveToTrash(bool);
- /** should we allow checksum validation to fail? set to true to workaround corrupted checksums **/
- bool allowChecksumValidationFail() const;
-
bool showMainDialogAsNormalWindow() const;
static bool setConfDir(const QString &value);
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 8fb05024b..f54e41c68 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -28,8 +28,6 @@
#include "propagatedownloadencrypted.h"
#include "common/vfs.h"
-#include "configfile.h"
-
#include <QLoggingCategory>
#include <QNetworkAccessManager>
#include <QFileInfo>
@@ -40,11 +38,6 @@
#include <unistd.h>
#endif
-namespace {
- constexpr quint16 numChecksumFailuresAllowed = 1;
- constexpr char *checksumFailureDbRecordPrefix = "ChecksumValidationFailed_";
-}
-
namespace OCC {
Q_LOGGING_CATEGORY(lcGetJob, "nextcloud.sync.networkjob.get", QtInfoMsg)
@@ -830,38 +823,8 @@ void PropagateDownloadFile::slotGetFinished()
validator->start(_tmpFile.fileName(), checksumHeader);
}
-void PropagateDownloadFile::slotChecksumFail(const QString &errMsg, const QByteArray &checksumType, const QByteArray &checksum, const QString &filePath)
-{
- if (!checksumType.isEmpty() && !checksum.isEmpty() && !filePath.isEmpty()) {
- ConfigFile cfgFile;
-
- if (cfgFile.allowChecksumValidationFail()) {
- const auto key = QString(checksumFailureDbRecordPrefix + _item->_fileId);
- const QStringList mismatchEntryForFileSplitted = propagator()->_journal->keyValueStoreGet(key).toString().split(":", QString::SkipEmptyParts);
- const QByteArray mismatchChecksumForFile = mismatchEntryForFileSplitted.size() > 0 ? mismatchEntryForFileSplitted[0].toUtf8() : QByteArray();
- const auto numChecksumMismatchCases = mismatchEntryForFileSplitted.size() > 1 ? mismatchEntryForFileSplitted[1].toInt() : 0;
-
- // format must be CHECKSUM:COUNT
- Q_ASSERT(mismatchEntryForFileSplitted.size() != 1);
- if (mismatchEntryForFileSplitted.size() == 1) {
- qCCritical(lcPropagateDownload) << "mismatchEntryForFile has incorrect format. Should be CHECKSUM:COUNT";
- }
-
- if (numChecksumMismatchCases < numChecksumFailuresAllowed || mismatchChecksumForFile != checksum) {
- // not enough failures or different checksum this time
- qCInfo(lcPropagateDownload) << "Checksum validation has failed" << numChecksumMismatchCases << " times, with previous checksum<" << mismatchChecksumForFile << "> and, current checksum<" << checksum << ">, but, allowChecksumValidationFail is set.Let's give it another try...";
- const auto numCasesToSet = mismatchChecksumForFile != checksum ? 1 : numChecksumMismatchCases + 1;
- const QString value = QString::fromUtf8(checksum) + QStringLiteral(":") + QString::number(numCasesToSet);
- propagator()->_journal->keyValueStoreSet(key, value);
- } else {
- propagator()->_journal->keyValueStoreDelete(key);
- qCInfo(lcPropagateDownload) << "Checksum validation has failed" << numChecksumMismatchCases << " times, but, allowChecksumValidationFail is set, so, let's continue...";
- startContentChecksumCompute(checksumType, filePath);
- return;
- }
- }
- }
-
+void PropagateDownloadFile::slotChecksumFail(const QString &errMsg)
+{
FileSystem::remove(_tmpFile.fileName());
propagator()->_anotherSyncNeeded = true;
done(SyncFileItem::SoftError, errMsg); // tr("The file downloaded with a broken checksum, will be redownloaded."));
@@ -889,18 +852,6 @@ void PropagateDownloadFile::deleteExistingFolder()
}
}
-void PropagateDownloadFile::startContentChecksumCompute(const QByteArray &checksumType, const QString &path)
-{
- qCInfo(lcPropagateDownload) << "Start checksum compute with checksumType:" << checksumType << " for path:" << path;
- // Compute the content checksum.
- const auto computeChecksum = new ComputeChecksum(this);
- computeChecksum->setChecksumType(checksumType);
-
- connect(computeChecksum, &ComputeChecksum::done,
- this, &PropagateDownloadFile::contentChecksumComputed);
- computeChecksum->start(path);
-}
-
namespace { // Anonymous namespace for the recall feature
static QString makeRecallFileName(const QString &fn)
{
@@ -989,9 +940,13 @@ void PropagateDownloadFile::transmissionChecksumValidated(const QByteArray &chec
return contentChecksumComputed(checksumType, checksum);
}
- startContentChecksumCompute(theContentChecksumType, _tmpFile.fileName());
+ // Compute the content checksum.
+ auto computeChecksum = new ComputeChecksum(this);
+ computeChecksum->setChecksumType(theContentChecksumType);
- propagator()->_journal->keyValueStoreDelete(QString(checksumFailureDbRecordPrefix + _item->_fileId));
+ connect(computeChecksum, &ComputeChecksum::done,
+ this, &PropagateDownloadFile::contentChecksumComputed);
+ computeChecksum->start(_tmpFile.fileName());
}
void PropagateDownloadFile::contentChecksumComputed(const QByteArray &checksumType, const QByteArray &checksum)
diff --git a/src/libsync/propagatedownload.h b/src/libsync/propagatedownload.h
index 963bf1055..31f174928 100644
--- a/src/libsync/propagatedownload.h
+++ b/src/libsync/propagatedownload.h
@@ -202,14 +202,12 @@ private slots:
void abort(PropagatorJob::AbortType abortType) override;
void slotDownloadProgress(qint64, qint64);
- void slotChecksumFail(const QString &errMsg, const QByteArray &checksumType, const QByteArray &checksum, const QString &filePath);
+ void slotChecksumFail(const QString &errMsg);
private:
void startAfterIsEncryptedIsChecked();
void deleteExistingFolder();
- void startContentChecksumCompute(const QByteArray &checksumType, const QString &path);
-
qint64 _resumeStart;
qint64 _downloadProgress;
QPointer<GETFileJob> _job;
diff --git a/test/testchecksumvalidator.cpp b/test/testchecksumvalidator.cpp
index a7e07d85b..82c1b1070 100644
--- a/test/testchecksumvalidator.cpp
+++ b/test/testchecksumvalidator.cpp
@@ -42,7 +42,8 @@ using namespace OCC::Utility;
_successDown = true;
}
- void slotDownError(const QString &errMsg, const QByteArray&, const QByteArray&, const QString&) {
+ void slotDownError(const QString &errMsg)
+ {
QCOMPARE(_expectedError, errMsg);
_errorSeen = true;
}