From: Kevin Ottens Date: Thu, 2 Jul 2020 15:24:58 +0000 (+0200) Subject: Update the metadata table with encryption info before discovery X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~116^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0b1cf6913447cee6b94db885c1b00292edbf8d86;p=nextcloud-desktop.git Update the metadata table with encryption info before discovery When the ClientSideEncryption object is fed, also serialize the encryption info of the folders inside the metadata table. Signed-off-by: Kevin Ottens --- diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 1875100ef..cd20bf4be 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -869,10 +869,53 @@ void SyncEngine::startSync() } } -void SyncEngine::onFolderEncryptedStatusFetchDone() +void SyncEngine::onFolderEncryptedStatusFetchDone(const QHash &values) { disconnect(_account->e2e(), &ClientSideEncryption::folderEncryptedStatusFetchDone, this, &SyncEngine::onFolderEncryptedStatusFetchDone); + + Q_ASSERT(_remotePath.startsWith('/')); + const auto rootPath = [=]() { + const auto result = _remotePath; + if (result.startsWith('/')) { + return result.mid(1); + } else { + return result; + } + }(); + + std::for_each(values.constKeyValueBegin(), values.constKeyValueEnd(), [=](const std::pair &pair) { + const auto key = pair.first; + const auto value = pair.second; + + if (!key.startsWith(rootPath)) { + return; + } + + Q_ASSERT(key.endsWith('/')); + const auto path = key.mid(rootPath.length()).chopped(1); + + if (path.isEmpty()) { + // We don't store metadata about the root + return; + } + + SyncJournalFileRecord rec; + _journal->getFileRecordByE2eMangledName(path, &rec); + + if (!rec.isValid()) { + _journal->getFileRecord(path, &rec); + } + + if (!rec.isValid()) { + // We don't know that folder yet anyway... + return; + } + + rec._isE2eEncrypted = value; + _journal->setFileRecord(rec); + }); + slotStartDiscovery(); } diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 7f21eee3e..d186bc627 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -168,7 +168,7 @@ signals: void seenLockedFile(const QString &fileName); private slots: - void onFolderEncryptedStatusFetchDone(); + void onFolderEncryptedStatusFetchDone(const QHash &values); void slotStartDiscovery(); void slotFolderDiscovered(bool local, const QString &folder);