mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Checksums: Prepare 'supported checksums' capability #3735
It currently always returns the empty list and thus has no effect.
This commit is contained in:
parent
24c41ed0da
commit
3812fd0866
5 changed files with 33 additions and 14 deletions
|
@ -38,4 +38,9 @@ int Capabilities::publicLinkExpireDateDays() const
|
|||
return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date"].toMap()["days"].toInt();
|
||||
}
|
||||
|
||||
QStringList Capabilities::supportedChecksumTypes() const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
bool publicLinkEnforcePassword() const;
|
||||
bool publicLinkEnforceExpireDate() const;
|
||||
int publicLinkExpireDateDays() const;
|
||||
QStringList supportedChecksumTypes() const;
|
||||
|
||||
private:
|
||||
QVariantMap _capabilities;
|
||||
|
|
|
@ -213,6 +213,18 @@ void PropagateUploadFileQNAM::start()
|
|||
// in any case, the validator will emit signal startUpload to let the flow
|
||||
// continue in slotStartUpload here.
|
||||
TransmissionChecksumValidator *validator = new TransmissionChecksumValidator(filePath, this);
|
||||
|
||||
// If the config file does not specify a checksum type but the
|
||||
// server supports it choose a type based on that.
|
||||
if (validator->checksumType().isEmpty()) {
|
||||
QStringList checksumTypes = _propagator->account()->capabilities().supportedChecksumTypes();
|
||||
if (!checksumTypes.isEmpty()) {
|
||||
// TODO: We might want to prefer some types over others instead
|
||||
// of choosing the first.
|
||||
validator->setChecksumType(checksumTypes.first());
|
||||
}
|
||||
}
|
||||
|
||||
connect(validator, SIGNAL(validated(QByteArray)), this, SLOT(slotStartUpload(QByteArray)));
|
||||
validator->uploadValidation();
|
||||
}
|
||||
|
|
|
@ -17,32 +17,29 @@
|
|||
#include "syncfileitem.h"
|
||||
#include "propagatorjobs.h"
|
||||
#include "configfile.h"
|
||||
#include "account.h"
|
||||
|
||||
#include <qtconcurrentrun.h>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
TransmissionChecksumValidator::TransmissionChecksumValidator(const QString& filePath, QObject *parent)
|
||||
:QObject(parent),
|
||||
: QObject(parent),
|
||||
_filePath(filePath)
|
||||
{
|
||||
|
||||
// If the config file specifies a checksum type, use that.
|
||||
ConfigFile cfg;
|
||||
_checksumType = cfg.transmissionChecksum();
|
||||
}
|
||||
|
||||
void TransmissionChecksumValidator::setChecksumType( const QByteArray& type )
|
||||
void TransmissionChecksumValidator::setChecksumType(const QString& type)
|
||||
{
|
||||
_checksumType = type;
|
||||
}
|
||||
|
||||
QString TransmissionChecksumValidator::checksumType() const
|
||||
{
|
||||
QString checksumType = _checksumType;
|
||||
if( checksumType.isEmpty() ) {
|
||||
ConfigFile cfg;
|
||||
checksumType = cfg.transmissionChecksum();
|
||||
}
|
||||
|
||||
return checksumType;
|
||||
return _checksumType;
|
||||
}
|
||||
|
||||
void TransmissionChecksumValidator::uploadValidation()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "owncloudlib.h"
|
||||
#include "accountfwd.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
|
@ -53,9 +54,12 @@ public:
|
|||
*/
|
||||
void downloadValidation( const QByteArray& checksumHeader );
|
||||
|
||||
// This is only used in test cases (by now). This class reads the required
|
||||
// test case from the config file.
|
||||
void setChecksumType(const QByteArray &type );
|
||||
/**
|
||||
* By default the checksum type is read from the config file, but can be overridden
|
||||
* with this method.
|
||||
*/
|
||||
void setChecksumType(const QString& type);
|
||||
|
||||
QString checksumType() const;
|
||||
|
||||
signals:
|
||||
|
@ -67,7 +71,7 @@ private slots:
|
|||
void slotDownloadChecksumCalculated();
|
||||
|
||||
private:
|
||||
QByteArray _checksumType;
|
||||
QString _checksumType;
|
||||
QByteArray _expectedHash;
|
||||
QByteArray _checksumHeader;
|
||||
|
||||
|
|
Loading…
Reference in a new issue