Change EncryptFolderJob path convention
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 7 Dec 2020 17:12:45 +0000 (18:12 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:22 +0000 (10:59 +0100)
It had a different path convention than all the other jobs, most likely
for legacy reasons because of the tight coupling it had to the settings
dialog.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/gui/accountsettings.cpp
src/libsync/encryptfolderjob.cpp
src/libsync/propagateremotemkdir.cpp

index d5606ec73fa7173b1ee6406f766c3e2ba550c7d6..6d86182366ab4d3ee6e8969f8c1c19e5794568ba 100644 (file)
@@ -302,7 +302,12 @@ void AccountSettings::slotMarkSubfolderEncrypted(const FolderStatusModel::SubFol
         return;
     }
 
-    auto job = new OCC::EncryptFolderJob(accountsState()->account(), folderInfo->_path, folderInfo->_fileId, this);
+    // Folder info have directory paths in Foo/Bar/ convention...
+    Q_ASSERT(!folderInfo->_path.startsWith('/') && folderInfo->_path.endsWith('/'));
+    // But EncryptFolderJob expects directory path Foo/Bar convention
+    const auto path = folderInfo->_path.chopped(1);
+
+    auto job = new OCC::EncryptFolderJob(accountsState()->account(), path, folderInfo->_fileId, this);
     connect(job, &OCC::EncryptFolderJob::finished, this, &AccountSettings::slotEncryptFolderFinished);
     job->start();
 }
index 2fa091ae4f2455bed7a69c2c8430f965a134ea5f..8a3d5b8fbb414cf6b16acb5ce7f5c0b368a98aa7 100644 (file)
@@ -45,7 +45,7 @@ QString EncryptFolderJob::errorString() const
 
 void EncryptFolderJob::slotEncryptionFlagSuccess(const QByteArray &fileId)
 {
-    _account->e2e()->setFolderEncryptedStatus(_path, true);
+    _account->e2e()->setFolderEncryptedStatus(_path + '/', true);
 
     auto lockJob = new LockEncryptFolderApiJob(_account, fileId, this);
     connect(lockJob, &LockEncryptFolderApiJob::success,
index f29c126bbf79aaaa8bb53e4e96cb98b1cd9742f8..17143a21c1da6a251266c73dcccd54522c06f17a 100644 (file)
@@ -240,8 +240,7 @@ void PropagateRemoteMkdir::slotMkcolJobFinished()
         // 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
-        // (otherwise we won't store the right string in the e2e object)
-        const auto path = QString(_job->path().mid(1) + '/');
+        const auto path = _job->path().mid(1);
 
         auto job = new OCC::EncryptFolderJob(propagator()->account(), path, _item->_fileId, this);
         connect(job, &OCC::EncryptFolderJob::finished, this, &PropagateRemoteMkdir::slotEncryptFolderFinished);