mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-12 22:24:28 +03:00
[CSE] Fetch the Folder information for encryption status
This commit is contained in:
parent
387737d908
commit
6f35cbff6b
3 changed files with 51 additions and 18 deletions
|
@ -43,9 +43,6 @@ public:
|
|||
void setTokenForFolder(const QByteArray& folder, const QByteArray& token);
|
||||
QByteArray tokenForFolder(const QByteArray& folder) const;
|
||||
|
||||
//TODO: Perhaps mode this to FolderStatusModel
|
||||
// (as it makes sense, but it increase the chance
|
||||
// of conflicts).
|
||||
void fetchFolderEncryptedStatus();
|
||||
|
||||
// to be used together with FolderStatusModel::FolderInfo::_path.
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "syncengine.h"
|
||||
#include "propagateremotedelete.h"
|
||||
#include "common/asserts.h"
|
||||
#include "networkjobs.h"
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QFileInfo>
|
||||
|
@ -177,29 +178,60 @@ void PropagateUploadFileCommon::start()
|
|||
* this by no means is a finished job, but a first step.
|
||||
*/
|
||||
if (propagator()->account()->capabilities().clientSideEncryptionAvaliable()) {
|
||||
qDebug() << "Uploading to Remote Folder: " << propagator()->_remoteFolder;
|
||||
qDebug() << "Uploading from Local Dir" << propagator()->_localDir;
|
||||
qDebug() << "Local File" << _item->_file;
|
||||
qDebug() << QDir::cleanPath(propagator()->account()->url().path() + QLatin1Char('/')
|
||||
+ propagator()->account()->davPath() + propagator()->_remoteFolder + _item->_file);
|
||||
|
||||
//TODO: Those shall die.
|
||||
/* If the file is in a encrypted-enabled nextcloud instance, we need to
|
||||
* do the long road: Fetch the folder status of the encrypted bit,
|
||||
* if it's encrypted, find the ID of the folder.
|
||||
* lock the folder using it's id.
|
||||
* download the metadata
|
||||
* update the metadata
|
||||
* upload the file
|
||||
* upload the metadata
|
||||
* unlock the folder.
|
||||
*
|
||||
* If the folder is unencrypted we just follow the old way.
|
||||
*/
|
||||
auto getEncryptedStatus = new GetFolderEncryptStatus(propagator()->account());
|
||||
connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusReceived,
|
||||
this, &PropagateUploadFileCommon::slotFolderEncryptedStatusFetched);
|
||||
connect(getEncryptedStatus, &GetFolderEncryptStatus::encryptStatusError,
|
||||
this, &PropagateUploadFileCommon::slotFolderEncryptedStatusError);
|
||||
getEncryptedStatus->start();
|
||||
} else {
|
||||
_fileToUpload._file = _item->_file;
|
||||
_fileToUpload._size = _item->_size;
|
||||
_fileToUpload._path = propagator()->getFilePath(_fileToUpload._file);
|
||||
} else {
|
||||
_fileToUpload._file = _item->_file;
|
||||
_fileToUpload._size = _item->_size;
|
||||
_fileToUpload._path = propagator()->getFilePath(_fileToUpload._file);
|
||||
startUploadRawFile();
|
||||
startUploadFile();
|
||||
}
|
||||
}
|
||||
void PropageteUploadFileCommon::startUploadEncryptedFile()
|
||||
|
||||
void PropagateUploadFileCommon::slotFolderEncryptedStatusFetched(const QMap<QString, bool>& result)
|
||||
{
|
||||
qDebug() << "####################################";
|
||||
qDebug() << "Encrypted Status Result by folder:";
|
||||
for(const auto& path : result.keys()) {
|
||||
qDebug() << result[path] << path;
|
||||
}
|
||||
qDebug() << "Uploading to Remote Folder: " << propagator()->_remoteFolder;
|
||||
qDebug() << "Uploading from Local Dir" << propagator()->_localDir;
|
||||
qDebug() << "Local File" << _item->_file;
|
||||
qDebug() << QDir::cleanPath(propagator()->account()->url().path() + QLatin1Char('/')
|
||||
+ propagator()->account()->davPath() + propagator()->_remoteFolder + _item->_file);
|
||||
qDebug() << "###################################";
|
||||
qDebug() << "Retrieved correctly the encrypted status of the folders." << result;
|
||||
}
|
||||
|
||||
void PropagateUploadFileCommon::slotFolderEncryptedStatusError(int error)
|
||||
{
|
||||
qDebug() << "Failed to retrieve the status of the folders." << error;
|
||||
}
|
||||
|
||||
|
||||
void PropagateUploadFileCommon::startUploadEncryptedFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PropagateUploadFileCommon::startUploadRawFile() {
|
||||
void PropagateUploadFileCommon::startUploadFile() {
|
||||
if (propagator()->_abortRequested.fetchAndAddRelaxed(0)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ public:
|
|||
/* start should setup the file, path and size that will be send to the server */
|
||||
void start() Q_DECL_OVERRIDE;
|
||||
void startUploadEncryptedFile();
|
||||
void startUploadRawFile();
|
||||
void startUploadFile();
|
||||
bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < propagator()->smallFileSize(); }
|
||||
|
||||
private slots:
|
||||
|
@ -278,6 +278,10 @@ private slots:
|
|||
void slotReplyAbortFinished();
|
||||
void slotPollFinished();
|
||||
|
||||
// Encryption Stuff
|
||||
void slotFolderEncryptedStatusFetched(const QMap<QString, bool>& result);
|
||||
void slotFolderEncryptedStatusError(int error);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Prepares the abort e.g. connects proper signals and slots
|
||||
|
|
Loading…
Reference in a new issue