From dd83efb54317fbf299232275667c0afb996fc627 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Mon, 1 Feb 2021 16:52:12 +0100 Subject: [PATCH] The e2eMangledName was relative to the remote folder, repair it This got broken during the huge discovery refactoring. I wrongly passed the mangled name as is out of discovery, but coming from listing jobs it was fully qualified while the jobs at propagation time and the db expect those paths to be relative to the remote folder. Signed-off-by: Kevin Ottens --- src/libsync/discovery.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index dbc90bd04..6c0254600 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -163,7 +163,13 @@ void ProcessDirectoryJob::process() // On the server the path is mangled in case of E2EE if (!e.serverEntry.e2eMangledName.isEmpty()) { - path._server = e.serverEntry.e2eMangledName; + Q_ASSERT(_discoveryData->_remoteFolder.startsWith('/')); + Q_ASSERT(_discoveryData->_remoteFolder.endsWith('/')); + + const auto rootPath = _discoveryData->_remoteFolder.mid(1); + Q_ASSERT(e.serverEntry.e2eMangledName.startsWith(rootPath)); + + path._server = e.serverEntry.e2eMangledName.mid(rootPath.length()); } // If the filename starts with a . we consider it a hidden file @@ -398,8 +404,19 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( item->_etag = serverEntry.etag; item->_directDownloadUrl = serverEntry.directDownloadUrl; item->_directDownloadCookies = serverEntry.directDownloadCookies; - item->_encryptedFileName = serverEntry.e2eMangledName; item->_isEncrypted = serverEntry.isE2eEncrypted; + item->_encryptedFileName = [=] { + if (serverEntry.e2eMangledName.isEmpty()) { + return QString(); + } + + Q_ASSERT(_discoveryData->_remoteFolder.startsWith('/')); + Q_ASSERT(_discoveryData->_remoteFolder.endsWith('/')); + + const auto rootPath = _discoveryData->_remoteFolder.mid(1); + Q_ASSERT(serverEntry.e2eMangledName.startsWith(rootPath)); + return serverEntry.e2eMangledName.mid(rootPath.length()); + }(); // Check for missing server data {