// If it's not a move it's just a local-NEW
if (!moveCheck()) {
- postProcessLocalNew();
- finalize();
- return;
+ const bool isRootEncryptedFolderRename = base._isE2eEncrypted;
+ if (isRootEncryptedFolderRename) {
+ // if we're renaming the root encrypted folder, we'd need to mark it's NEW item with _isEncrypted true so the further processing will work correctly
+ item->_isEncrypted = true;
+ }
+ postProcessLocalNew();
+ finalize();
+ return;
}
// Check local permission if we are allowed to put move the file here
private:
QScopedPointer<PropagateItemJob> _restoreJob;
+ JobParallelism _parallelism;
public:
PropagateItemJob(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
: PropagatorJob(propagator)
, _item(item)
+ , _parallelism(FullParallelism)
{
+ _parallelism = (_item->_isEncrypted || hasEncryptedAncestor()) ? WaitForFinished : FullParallelism;
}
~PropagateItemJob();
return true;
}
+ virtual JobParallelism parallelism() override { return _parallelism; }
+
SyncFileItemPtr _item;
public slots:
Q_LOGGING_CATEGORY(lcPropagateRemoteDelete, "nextcloud.sync.propagator.remotedelete", QtInfoMsg)
-PropagatorJob::JobParallelism PropagateRemoteDelete::parallelism()
-{
- return _item->_encryptedFileName.isEmpty() ? FullParallelism : WaitForFinished;
-}
-
void PropagateRemoteDelete::start()
{
if (propagator()->_abortRequested)
: PropagateItemJob(propagator, item)
{
}
- JobParallelism parallelism() override;
void start() override;
void createDeleteJob(const QString &filename);
void abort(PropagatorJob::AbortType abortType) override;
: PropagateItemJob(propagator, item)
, _deleteExisting(false)
, _uploadEncryptedHelper(nullptr)
- , _parallelism(FullParallelism)
+ , _isEncryptedRootFolder(_item->_isEncrypted && _item->_encryptedFileName.isEmpty())
{
const auto path = _item->_file;
const auto slashPosition = path.lastIndexOf('/');
if (!ok) {
return;
}
-
- if (hasEncryptedAncestor()) {
- _parallelism = WaitForFinished;
- }
-}
-
-PropagatorJob::JobParallelism PropagateRemoteMkdir::parallelism()
-{
- return _parallelism;
}
void PropagateRemoteMkdir::start()
return;
}
- if (!_uploadEncryptedHelper) {
+ if (!_uploadEncryptedHelper && !_isEncryptedRootFolder) {
success();
} else {
// We still need to mark that folder encrypted
// We're expecting directory path in /Foo/Bar convention...
Q_ASSERT(_job->path().startsWith('/') && !_job->path().endsWith('/'));
// But encryption job expect it in Foo/Bar/ convention
- const auto path = _job->path().mid(1);
+ const auto path = _isEncryptedRootFolder ? _job->path() : _job->path().mid(1);
auto job = new OCC::EncryptFolderJob(propagator()->account(), propagator()->_journal, path, _item->_fileId, this);
connect(job, &OCC::EncryptFolderJob::finished, this, &PropagateRemoteMkdir::slotEncryptFolderFinished);
QPointer<AbstractNetworkJob> _job;
bool _deleteExisting;
PropagateUploadEncrypted *_uploadEncryptedHelper;
- JobParallelism _parallelism;
friend class PropagateDirectory; // So it can access the _item;
public:
PropagateRemoteMkdir(OwncloudPropagator *propagator, const SyncFileItemPtr &item);
- JobParallelism parallelism() override;
-
void start() override;
void abort(PropagatorJob::AbortType abortType) override;
void propfindResult(const QVariantMap &);
void propfindError();
void success();
+
+private:
+ bool _isEncryptedRootFolder = false;
};
}
if (origin == _item->_renameTarget) {
// The parent has been renamed already so there is nothing more to do.
+
+ if (!_item->_encryptedFileName.isEmpty()) {
+ const auto path = _item->_file;
+ const auto slashPosition = path.lastIndexOf('/');
+ const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
+
+ SyncJournalFileRecord parentRec;
+ bool ok = propagator()->_journal->getFileRecord(parentPath, &parentRec);
+ if (!ok) {
+ done(SyncFileItem::NormalError);
+ return;
+ }
+
+ // We should be encrypted as well since our parent is
+ const auto remoteParentPath = parentRec._e2eMangledName.isEmpty() ? parentPath : parentRec._e2eMangledName;
+
+ const auto lastSlashPosition = _item->_encryptedFileName.lastIndexOf('/');
+ const auto encryptedName = slashPosition >= 0 ? _item->_encryptedFileName.mid(lastSlashPosition + 1) : QString();
+
+ if (!encryptedName.isEmpty()) {
+ _item->_encryptedFileName = remoteParentPath + "/" + encryptedName;
+ }
+
+ }
+
finalize();
return;
}
, _finished(false)
, _deleteExisting(false)
, _aborting(false)
- , _parallelism(FullParallelism)
, _uploadEncryptedHelper(nullptr)
, _uploadingEncrypted(false)
{
if (!ok) {
return;
}
-
- if (hasEncryptedAncestor()) {
- _parallelism = WaitForFinished;
- }
-}
-
-PropagatorJob::JobParallelism PropagateUploadFileCommon::parallelism()
-{
- return _parallelism;
}
void PropagateUploadFileCommon::setDeleteExisting(bool enabled)
};
UploadFileInfo _fileToUpload;
QByteArray _transmissionChecksumHeader;
- JobParallelism _parallelism;
public:
PropagateUploadFileCommon(OwncloudPropagator *propagator, const SyncFileItemPtr &item);
- JobParallelism parallelism() override;
-
/**
* Whether an existing entity with the same name may be deleted before
* the upload.