[CSE] Pass the folder to the GetEncryptionStatus

Sometimes we are only interested in folders.
This commit is contained in:
Tomaz Canabrava 2017-12-07 17:32:35 +01:00
parent 66aecb9626
commit 863e86138f
3 changed files with 13 additions and 6 deletions

View file

@ -984,7 +984,7 @@ void ClientSideEncryption::getPublicKeyFromServer()
void ClientSideEncryption::fetchFolderEncryptedStatus() { void ClientSideEncryption::fetchFolderEncryptedStatus() {
_refreshingEncryptionStatus = true; _refreshingEncryptionStatus = true;
auto getEncryptedStatus = new GetFolderEncryptStatus(_account); auto getEncryptedStatus = new GetFolderEncryptStatus(_account, QString());
connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusReceived, connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusReceived,
this, &ClientSideEncryption::folderEncryptedStatusFetched); this, &ClientSideEncryption::folderEncryptedStatusFetched);
connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusError, connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusError,
@ -1483,8 +1483,8 @@ bool GetMetadataApiJob::finished()
return true; return true;
} }
GetFolderEncryptStatus::GetFolderEncryptStatus(const AccountPtr& account, QObject *parent) GetFolderEncryptStatus::GetFolderEncryptStatus(const AccountPtr& account, const QString& folder, QObject *parent)
: OCC::AbstractNetworkJob(account, QStringLiteral("remote.php/webdav"), parent) : OCC::AbstractNetworkJob(account, QStringLiteral("remote.php/webdav"), parent), _folder(folder)
{ {
} }
@ -1499,7 +1499,8 @@ void GetFolderEncryptStatus::start()
QBuffer *buf = new QBuffer(this); QBuffer *buf = new QBuffer(this);
buf->setData(xml); buf->setData(xml);
buf->open(QIODevice::ReadOnly); buf->open(QIODevice::ReadOnly);
sendRequest("PROPFIND", Utility::concatUrlPath(account()->url(), path()), req, buf); QString tmpPath = path() + (!_folder.isEmpty() ? "/" + _folder : QString());
sendRequest("PROPFIND", Utility::concatUrlPath(account()->url(), tmpPath), req, buf);
AbstractNetworkJob::start(); AbstractNetworkJob::start();
} }

View file

@ -341,7 +341,7 @@ class OWNCLOUDSYNC_EXPORT GetFolderEncryptStatus : public AbstractNetworkJob
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit GetFolderEncryptStatus (const AccountPtr &account, QObject *parent = 0); explicit GetFolderEncryptStatus (const AccountPtr &account, const QString& folder, QObject *parent = 0);
public slots: public slots:
void start() override; void start() override;
@ -352,6 +352,8 @@ protected:
signals: signals:
void encryptStatusReceived(const QMap<QString, bool> folderMetadata2EncryptionStatus); void encryptStatusReceived(const QMap<QString, bool> folderMetadata2EncryptionStatus);
void encryptStatusError(int statusCode); void encryptStatusError(int statusCode);
private:
QString _folder;
}; };
} // namespace OCC } // namespace OCC

View file

@ -192,7 +192,11 @@ void PropagateUploadFileCommon::start()
* *
* If the folder is unencrypted we just follow the old way. * If the folder is unencrypted we just follow the old way.
*/ */
auto getEncryptedStatus = new GetFolderEncryptStatus(propagator()->account()); QFileInfo info(_item->_file);
auto getEncryptedStatus = new GetFolderEncryptStatus(propagator()->account(),
info.path());
connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusReceived, connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusReceived,
this, &PropagateUploadFileCommon::slotFolderEncryptedStatusFetched); this, &PropagateUploadFileCommon::slotFolderEncryptedStatusFetched);
connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusError, connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusError,