mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
Checksums: Content checksums for all uploads #4375
This commit is contained in:
parent
ffa78b99d9
commit
7ed7512f27
3 changed files with 17 additions and 9 deletions
|
@ -114,6 +114,15 @@ bool downloadChecksumEnabled()
|
||||||
return enabled;
|
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)
|
ComputeChecksum::ComputeChecksum(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,10 @@ bool uploadChecksumEnabled();
|
||||||
/// Checks OWNCLOUD_DISABLE_CHECKSUM_DOWNLOAD
|
/// Checks OWNCLOUD_DISABLE_CHECKSUM_DOWNLOAD
|
||||||
bool downloadChecksumEnabled();
|
bool downloadChecksumEnabled();
|
||||||
|
|
||||||
|
/// Checks OWNCLOUD_CONTENT_CHECKSUM_TYPE (default: SHA1)
|
||||||
|
QByteArray contentChecksumType();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the checksum of a file.
|
* Computes the checksum of a file.
|
||||||
* \ingroup libsync
|
* \ingroup libsync
|
||||||
|
|
|
@ -219,23 +219,18 @@ void PropagateUploadFileQNAM::slotComputeContentChecksum()
|
||||||
|
|
||||||
_stopWatch.start();
|
_stopWatch.start();
|
||||||
|
|
||||||
QByteArray contentChecksumType;
|
QByteArray checksumType = 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";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maybe the discovery already computed the checksum?
|
// Maybe the discovery already computed the checksum?
|
||||||
if (_item->_contentChecksumType == contentChecksumType
|
if (_item->_contentChecksumType == checksumType
|
||||||
&& !_item->_contentChecksum.isEmpty()) {
|
&& !_item->_contentChecksum.isEmpty()) {
|
||||||
slotComputeTransmissionChecksum(contentChecksumType, _item->_contentChecksum);
|
slotComputeTransmissionChecksum(checksumType, _item->_contentChecksum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the content checksum.
|
// Compute the content checksum.
|
||||||
auto computeChecksum = new ComputeChecksum(this);
|
auto computeChecksum = new ComputeChecksum(this);
|
||||||
computeChecksum->setChecksumType(contentChecksumType);
|
computeChecksum->setChecksumType(checksumType);
|
||||||
|
|
||||||
connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
|
connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
|
||||||
SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray)));
|
SLOT(slotComputeTransmissionChecksum(QByteArray,QByteArray)));
|
||||||
|
|
Loading…
Reference in a new issue