Skip to content

Improve checksum handling #8015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/7999
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix support of adler32 checksums with Windows virtual files support

The validation device reported a size of 0 and thus the computations of the
checksums was aborted.

https://github.com/owncloud/client/issues/7999
https://github.com/owncloud/client/pull/8015
6 changes: 5 additions & 1 deletion src/common/checksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ QByteArray calcSha1(QIODevice *device)
#ifdef ZLIB_FOUND
QByteArray calcAdler32(QIODevice *device)
{
if (device->size() == 0)
{
return QByteArray();
}
QByteArray buf(BUFSIZE, Qt::Uninitialized);

unsigned int adler = adler32(0L, Z_NULL, 0);
Expand Down Expand Up @@ -354,7 +358,7 @@ void ValidateChecksumHeader::slotChecksumCalculated(const QByteArray &checksumTy
return;
}
if (checksum != _expectedChecksum) {
emit validationFailed(tr("The downloaded file does not match the checksum, it will be resumed."));
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);
Expand Down
4 changes: 2 additions & 2 deletions test/testchecksumvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace OCC::Utility;
}

void slotDownError( const QString& errMsg ) {
QVERIFY(_expectedError == errMsg );
QCOMPARE(_expectedError, errMsg);
_errorSeen = true;
}

Expand Down Expand Up @@ -196,7 +196,7 @@ using namespace OCC::Utility;

QTRY_VERIFY(_successDown);

_expectedError = QLatin1String("The downloaded file does not match the checksum, it will be resumed.");
_expectedError = QStringLiteral("The downloaded file does not match the checksum, it will be resumed. '543345' != '%1'").arg(QString::fromUtf8(_expected));
_errorSeen = false;
file->seek(0);
vali->start(_testfile, "Adler32:543345");
Expand Down