Checksum: Add env variables to disable #3735

This commit is contained in:
Christian Kamm 2015-10-15 09:39:49 +02:00
parent dff37e11eb
commit f1b500d3e0
4 changed files with 26 additions and 1 deletions

View file

@ -537,7 +537,11 @@ void PropagateDownloadFileQNAM::slotGetFinished()
ValidateChecksumHeader *validator = new ValidateChecksumHeader(this);
connect(validator, SIGNAL(validated(QByteArray)), this, SLOT(downloadFinished(QByteArray)));
connect(validator, SIGNAL(validationFailed(QString)), this, SLOT(slotChecksumFail(QString)));
validator->start(_tmpFile.fileName(), job->reply()->rawHeader(checkSumHeaderC));
auto checksumHeader = job->reply()->rawHeader(checkSumHeaderC);
if (!downloadChecksumEnabled()) {
checksumHeader.clear();
}
validator->start(_tmpFile.fileName(), checksumHeader);
}
void PropagateDownloadFileQNAM::slotChecksumFail( const QString& errMsg )

View file

@ -237,6 +237,9 @@ void PropagateUploadFileQNAM::start()
computeChecksum->setChecksumType(supportedChecksumTypes.first());
}
}
if (!uploadChecksumEnabled()) {
computeChecksum->setChecksumType(QByteArray());
}
connect(computeChecksum, SIGNAL(done(QByteArray,QByteArray)),
SLOT(slotStartUpload(QByteArray,QByteArray)));

View file

@ -49,6 +49,18 @@ bool parseChecksumHeader(const QByteArray& header, QByteArray* type, QByteArray*
return true;
}
bool uploadChecksumEnabled()
{
static bool enabled = qgetenv("OWNCLOUD_DISABLE_CHECKSUM_UPLOAD").isEmpty();
return enabled;
}
bool downloadChecksumEnabled()
{
static bool enabled = qgetenv("OWNCLOUD_DISABLE_CHECKSUM_DOWNLOAD").isEmpty();
return enabled;
}
ComputeChecksum::ComputeChecksum(QObject* parent)
: QObject(parent)
{

View file

@ -29,6 +29,12 @@ QByteArray makeChecksumHeader(const QByteArray& checksumType, const QByteArray&
/// Parses a checksum header
bool parseChecksumHeader(const QByteArray& header, QByteArray* type, QByteArray* checksum);
/// Checks OWNCLOUD_DISABLE_CHECKSUM_UPLOAD
bool uploadChecksumEnabled();
/// Checks OWNCLOUD_DISABLE_CHECKSUM_DOWNLOAD
bool downloadChecksumEnabled();
/**
* Computes the checksum of a file.
* \ingroup libsync