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 <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2021-02-01 16:52:12 +01:00 committed by allexzander (Rebase PR Action)
parent 2c8fa40fb6
commit dd83efb543

View file

@ -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
{