mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
Checksums: Use the first supported type if nothing is preferred
This commit is contained in:
parent
043350f49d
commit
09eea7f5f2
3 changed files with 19 additions and 1 deletions
|
@ -95,4 +95,15 @@ QByteArray Capabilities::preferredUploadChecksumType() const
|
|||
return _capabilities["checksums"].toMap()["preferredUploadType"].toByteArray();
|
||||
}
|
||||
|
||||
QByteArray Capabilities::uploadChecksumType() const
|
||||
{
|
||||
QByteArray preferred = preferredUploadChecksumType();
|
||||
if (!preferred.isEmpty())
|
||||
return preferred;
|
||||
QList<QByteArray> supported = supportedChecksumTypes();
|
||||
if (!supported.isEmpty())
|
||||
return supported.first();
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,13 @@ public:
|
|||
*/
|
||||
QByteArray preferredUploadChecksumType() const;
|
||||
|
||||
/**
|
||||
* Helper that returns the preferredUploadChecksumType() if set, or one
|
||||
* of the supportedChecksumTypes() if it isn't. May return an empty
|
||||
* QByteArray if no checksum types are supported.
|
||||
*/
|
||||
QByteArray uploadChecksumType() const;
|
||||
|
||||
private:
|
||||
QVariantMap _capabilities;
|
||||
};
|
||||
|
|
|
@ -261,7 +261,7 @@ void PropagateUploadFileQNAM::slotComputeTransmissionChecksum(const QByteArray&
|
|||
// Compute the transmission checksum.
|
||||
auto computeChecksum = new ComputeChecksum(this);
|
||||
if (uploadChecksumEnabled()) {
|
||||
computeChecksum->setChecksumType(_propagator->account()->capabilities().preferredUploadChecksumType());
|
||||
computeChecksum->setChecksumType(_propagator->account()->capabilities().uploadChecksumType());
|
||||
} else {
|
||||
computeChecksum->setChecksumType(QByteArray());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue