#include "capabilities.h"
+#include "configfile.h"
+
#include <QVariantMap>
namespace OCC {
return _capabilities["files_sharing"].toMap()["resharing"].toBool();
}
-QList<QByteArray> Capabilities::supportedChecksumTypes() const
+QList<QByteArray> Capabilities::supportedChecksumTypesRaw() const
{
return QList<QByteArray>();
}
+QList<QByteArray> Capabilities::supportedChecksumTypes() const
+{
+ auto list = supportedChecksumTypesRaw();
+ QByteArray cfgType = ConfigFile().transmissionChecksum().toLatin1();
+ if (!cfgType.isEmpty()) {
+ list.prepend(cfgType);
+ }
+ return list;
+}
+
+QByteArray Capabilities::preferredChecksumType() const
+{
+ auto list = supportedChecksumTypes();
+ if (list.isEmpty()) {
+ return QByteArray();
+ }
+ return list.first();
+}
+
}
bool sharePublicLinkEnforceExpireDate() const;
int sharePublicLinkExpireDateDays() const;
bool shareResharing() const;
+
+ /// Returns the checksum types the server explicitly advertises
+ QList<QByteArray> supportedChecksumTypesRaw() const;
+
+ /// Like supportedChecksumTypesRaw(), but includes the type from the config
QList<QByteArray> supportedChecksumTypes() const;
+ /// Returns the checksum type that should be used for new uploads.
+ QByteArray preferredChecksumType() const;
+
private:
QVariantMap _capabilities;
};
// Compute a new checksum.
auto computeChecksum = new ComputeChecksum(this);
-
- // If the config file does not specify a checksum type but the
- // server supports it, choose a type based on that.
- if (computeChecksum->checksumType().isEmpty()) {
- if (!supportedChecksumTypes.isEmpty()) {
- // TODO: We might want to prefer some types over others instead
- // of choosing the first.
- computeChecksum->setChecksumType(supportedChecksumTypes.first());
- }
- }
- if (!uploadChecksumEnabled()) {
+ if (uploadChecksumEnabled()) {
+ computeChecksum->setChecksumType(_propagator->account()->capabilities().preferredChecksumType());
+ } else {
computeChecksum->setChecksumType(QByteArray());
}
#include "transmissionchecksumvalidator.h"
#include "syncfileitem.h"
#include "propagatorjobs.h"
-#include "configfile.h"
#include "account.h"
#include <qtconcurrentrun.h>
ComputeChecksum::ComputeChecksum(QObject* parent)
: QObject(parent)
{
- // If the config file specifies a checksum type, use that.
- ConfigFile cfg;
- _checksumType = cfg.transmissionChecksum().toLatin1();
}
void ComputeChecksum::setChecksumType(const QByteArray& type)
explicit ComputeChecksum(QObject* parent = 0);
/**
- * By default the checksum type is read from the config file, but can be overridden
- * with this method.
+ * Sets the checksum type to be used. The default is empty.
*/
void setChecksumType(const QByteArray& type);