Better separate between absolute and relative paths on downloads

I wish this would be all driven by the type system instead of
error-prone string concatenation everywhere. That will be for a (much)
later refactoring hopefully.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-06-29 18:20:23 +02:00 committed by Kevin Ottens (Rebase PR Action)
parent 8a181adb3a
commit 8d5c79c219
3 changed files with 17 additions and 5 deletions

View file

@ -359,9 +359,13 @@ 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();
SyncJournalFileRecord parentRec;
propagator()->_journal->getFileRecordByE2eMangledName(remoteParentPath, &parentRec);
const auto parentPath = parentRec.isValid() ? parentRec._path : remoteParentPath;
propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec);
const auto parentPath = parentRec.isValid() ? parentRec._path : relativeRemoteParentPath;
_downloadEncryptedHelper = new PropagateDownloadEncrypted(propagator(), parentPath, _item, this);
connect(_downloadEncryptedHelper, &PropagateDownloadEncrypted::folderStatusNotEncrypted, [this] {

View file

@ -101,7 +101,11 @@ void PropagateDownloadEncrypted::checkFolderEncryptedMetadata(const QJsonDocumen
if (encryptedFilename == file.encryptedFilename) {
_encryptedInfo = file;
_item->_encryptedFileName = _item->_file;
_item->_file = _localParentPath + QLatin1Char('/') + _encryptedInfo.originalFilename;
if (!_localParentPath.isEmpty()) {
_item->_file = _localParentPath + QLatin1Char('/') + _encryptedInfo.originalFilename;
} else {
_item->_file = _encryptedInfo.originalFilename;
}
qCDebug(lcPropagateDownloadEncrypted) << "Found matching encrypted metadata for file, starting download";
emit folderStatusEncrypted();

View file

@ -174,9 +174,13 @@ void PropagateLocalMkdir::start()
!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(remoteParentPath, &parentRec);
const auto parentPath = parentRec.isValid() ? parentRec._path : remoteParentPath;
propagator()->_journal->getFileRecordByE2eMangledName(relativeRemoteParentPath, &parentRec);
const auto parentPath = parentRec.isValid() ? parentRec._path : relativeRemoteParentPath;
startDemanglingName(parentPath);
}
}