Use the servers checksum type by default

This commit is contained in:
Hannah von Reth 2020-07-24 17:16:28 +02:00 committed by Kevin Ottens
parent 8c3749cbe2
commit c1a91e91e7
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
5 changed files with 5 additions and 15 deletions

View file

@ -189,15 +189,6 @@ bool uploadChecksumEnabled()
return enabled;
}
QByteArray contentChecksumType()
{
static QByteArray type = qgetenv("OWNCLOUD_CONTENT_CHECKSUM_TYPE");
if (type.isNull()) { // can set to "" to disable checksumming
type = "SHA1";
}
return type;
}
static bool checksumComputationEnabled()
{
static bool enabled = qEnvironmentVariableIsEmpty("OWNCLOUD_DISABLE_CHECKSUM_COMPUTATIONS");

View file

@ -65,9 +65,6 @@ OCSYNC_EXPORT QByteArray parseChecksumHeaderType(const QByteArray &header);
/// Checks OWNCLOUD_DISABLE_CHECKSUM_UPLOAD
OCSYNC_EXPORT bool uploadChecksumEnabled();
/// Checks OWNCLOUD_CONTENT_CHECKSUM_TYPE (default: SHA1)
OCSYNC_EXPORT QByteArray contentChecksumType();
// Exported functions for the tests.
QByteArray OCSYNC_EXPORT calcMd5(QIODevice *device);
QByteArray OCSYNC_EXPORT calcSha1(QIODevice *device);

View file

@ -150,7 +150,9 @@ QList<QByteArray> Capabilities::supportedChecksumTypes() const
QByteArray Capabilities::preferredUploadChecksumType() const
{
return _capabilities["checksums"].toMap()["preferredUploadType"].toByteArray();
return qEnvironmentVariable("OWNCLOUD_CONTENT_CHECKSUM_TYPE",
_capabilities.value(QStringLiteral("checksums")).toMap()
.value(QStringLiteral("preferredUploadType"), QStringLiteral("SHA1")).toString()).toUtf8();
}
QByteArray Capabilities::uploadChecksumType() const

View file

@ -909,7 +909,7 @@ namespace { // Anonymous namespace for the recall feature
void PropagateDownloadFile::transmissionChecksumValidated(const QByteArray &checksumType, const QByteArray &checksum)
{
const auto theContentChecksumType = contentChecksumType();
const QByteArray theContentChecksumType = propagator()->account()->capabilities().preferredUploadChecksumType();
// Reuse transmission checksum as content checksum.
//

View file

@ -349,7 +349,7 @@ void PropagateUploadFileCommon::slotComputeContentChecksum()
// probably temporary one.
_item->_modtime = FileSystem::getModTime(filePath);
QByteArray checksumType = contentChecksumType();
const QByteArray checksumType = propagator()->account()->capabilities().preferredUploadChecksumType();
// Maybe the discovery already computed the checksum?
// Should I compute the checksum of the original (_item->_file)