mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-02-22 23:45:58 +01:00
Revert Added config parameter that allows to bypass checksum validation failure.
Signed-off-by: allexzander <blackslayer4@gmail.com>
This commit is contained in:
parent
76308d5155
commit
8122c63ebc
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user