Don't use getFileRecordByE2eMangledName in jobs anymore

Thanks to the new discovery algorithm we got both mangled and original
file names in the item so no need to go through the database for
nothing.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-12-07 16:33:36 +01:00
parent 66f24241d8
commit af00ef1cca
No known key found for this signature in database
GPG Key ID: 074BBBCB8DECC9E2
2 changed files with 4 additions and 49 deletions

View File

@ -384,12 +384,9 @@ void PropagateDownloadFile::start()
!account->e2e()->isFolderEncrypted(remoteParentPath + '/')) {
startAfterIsEncryptedIsChecked();
} else {
const auto slashPosition = remoteFilename.lastIndexOf('/');
const auto relativeRemoteParentPath = slashPosition >= 0 ? remoteFilename.left(slashPosition) : QString();
SyncJournalFileRecord parentRec;
propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec);
const auto parentPath = parentRec.isValid() ? parentRec._path : relativeRemoteParentPath;
const auto path = _item->_file;
const auto slashPosition = path.lastIndexOf('/');
const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
_downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), parentPath, _item, this);
connect(_downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusNotEncrypted, [this] {

View File

@ -134,31 +134,7 @@ void PropagateLocalMkdir::start()
if (propagator()->_abortRequested)
return;
const auto rootPath = [=]() {
const auto result = propagator()->remotePath();
if (result.startsWith('/')) {
return result.mid(1);
} else {
return result;
}
}();
const auto remotePath = QString(rootPath + _item->_file);
const auto remoteParentPath = remotePath.left(remotePath.lastIndexOf('/'));
const auto account = propagator()->account();
if (!account->capabilities().clientSideEncryptionAvailable() ||
!account->e2e()->isFolderEncrypted(remoteParentPath + '/')) {
startLocalMkdir();
} else {
const auto relativeRemotePath = _item->_file;
const auto slashPosition = relativeRemotePath.lastIndexOf('/');
const auto relativeRemoteParentPath = slashPosition >= 0 ? relativeRemotePath.left(slashPosition) : QString();
SyncJournalFileRecord parentRec;
propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec);
const auto parentPath = parentRec.isValid() ? parentRec._path : relativeRemoteParentPath;
startDemanglingName(parentPath);
}
startLocalMkdir();
}
void PropagateLocalMkdir::setDeleteExistingFile(bool enabled)
@ -223,24 +199,6 @@ void PropagateLocalMkdir::startLocalMkdir()
done(resultStatus);
}
void PropagateLocalMkdir::startDemanglingName(const QString &parentPath)
{
auto downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), parentPath, _item, this);
connect(downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusEncrypted,
this, &PropagateLocalMkdir::startLocalMkdir);
connect(downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusNotEncrypted, this, [this] {
// We were wrong after all? Actually might happen due to legacy clients creating broken encrypted folders
qCDebug(lcPropagateLocalMkdir) << "Parent of" << _item->_file << "wasn't encrypted, creating with the original name";
startLocalMkdir();
});
connect(downloadEncryptedHelper, &PropagateDownloadEncrypted::failed, [this] {
// This also might happen due to legacy clients creating broken encrypted folders...
qCDebug(lcPropagateLocalMkdir) << "Directory" << _item->_file << "doesn't exist in its parent metadata, creating with the original name";
startLocalMkdir();
});
downloadEncryptedHelper->start();
}
void PropagateLocalRename::start()
{
if (propagator()->_abortRequested)