From: Kevin Ottens Date: Tue, 30 Jun 2020 15:20:02 +0000 (+0200) Subject: Deal properly with encrypted item updates accross connections X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~125^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d2e8cd4469162b203de6d9aaad2618014813dcbf;p=nextcloud-desktop.git Deal properly with encrypted item updates accross connections In such cases we get a download for which _file is already the demangled name and _encryptedFileName has the mangled information. This is different to what we encountered so far where initially _file was mangled and _encryptedFileName was empty. Let's deal with that case properly. Signed-off-by: Kevin Ottens --- diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 94f3a99a5..473c5d70b 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -351,7 +351,8 @@ void PropagateDownloadFile::start() return result; } }(); - const auto remotePath = QString(rootPath + _item->_file); + const auto remoteFilename = _item->_encryptedFileName.isEmpty() ? _item->_file : _item->_encryptedFileName; + const auto remotePath = QString(rootPath + remoteFilename); const auto remoteParentPath = remotePath.left(remotePath.lastIndexOf('/')); const auto account = propagator()->account(); @@ -359,9 +360,8 @@ void PropagateDownloadFile::start() !account->e2e()->isFolderEncrypted(remoteParentPath + '/')) { startAfterIsEncryptedIsChecked(); } else { - const auto relativeRemotePath = _item->_file; - const auto slashPosition = relativeRemotePath.lastIndexOf('/'); - const auto relativeRemoteParentPath = slashPosition >= 0 ? relativeRemotePath.left(slashPosition) : QString(); + const auto slashPosition = remoteFilename.lastIndexOf('/'); + const auto relativeRemoteParentPath = slashPosition >= 0 ? remoteFilename.left(slashPosition) : QString(); SyncJournalFileRecord parentRec; propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec); diff --git a/src/libsync/propagatedownloadencrypted.cpp b/src/libsync/propagatedownloadencrypted.cpp index 80e407f8a..d91a7d351 100644 --- a/src/libsync/propagatedownloadencrypted.cpp +++ b/src/libsync/propagatedownloadencrypted.cpp @@ -29,7 +29,8 @@ void PropagateDownloadEncrypted::checkFolderEncryptedStatus() return result; } }(); - const auto remotePath = QString(rootPath + _item->_file); + const auto remoteFilename = _item->_encryptedFileName.isEmpty() ? _item->_file : _item->_encryptedFileName; + const auto remotePath = QString(rootPath + remoteFilename); const auto remoteParentPath = remotePath.left(remotePath.lastIndexOf('/')); auto getEncryptedStatus = new GetFolderEncryptStatusJob(_propagator->account(), remoteParentPath, this); @@ -100,7 +101,9 @@ void PropagateDownloadEncrypted::checkFolderEncryptedMetadata(const QJsonDocumen for (const EncryptedFile &file : files) { if (encryptedFilename == file.encryptedFilename) { _encryptedInfo = file; - _item->_encryptedFileName = _item->_file; + if (_item->_encryptedFileName.isEmpty()) { + _item->_encryptedFileName = _item->_file; + } if (!_localParentPath.isEmpty()) { _item->_file = _localParentPath + QLatin1Char('/') + _encryptedInfo.originalFilename; } else {