Better separate between absolute and relative paths on uploads

Yes... I still wish this would be all driven by the type system, would be
much less error-prone.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-06-30 16:04:55 +02:00 committed by Kevin Ottens (Rebase PR Action)
parent 8d5c79c219
commit 3204c15911
2 changed files with 11 additions and 7 deletions

View file

@ -111,8 +111,9 @@ void PropagateRemoteMkdir::slotMkdir()
return result;
}
}();
const auto path = QString(rootPath + _item->_file);
const auto parentPath = path.left(path.lastIndexOf('/'));
const auto path = _item->_file;
const auto slashPosition = path.lastIndexOf('/');
const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
SyncJournalFileRecord parentRec;
bool ok = propagator()->_journal->getFileRecord(parentPath, &parentRec);
@ -122,11 +123,12 @@ void PropagateRemoteMkdir::slotMkdir()
}
const auto remoteParentPath = parentRec._e2eMangledName.isEmpty() ? parentPath : parentRec._e2eMangledName;
const auto absoluteRemoteParentPath = remoteParentPath.isEmpty() ? rootPath : rootPath + remoteParentPath + '/';
const auto account = propagator()->account();
if (!account->capabilities().clientSideEncryptionAvailable() ||
(!account->e2e()->isFolderEncrypted(remoteParentPath + '/') &&
!account->e2e()->isAnyParentFolderEncrypted(remoteParentPath + '/'))) {
(!account->e2e()->isFolderEncrypted(absoluteRemoteParentPath) &&
!account->e2e()->isAnyParentFolderEncrypted(absoluteRemoteParentPath))) {
slotStartMkcolJob();
return;
}

View file

@ -179,8 +179,9 @@ void PropagateUploadFileCommon::start()
return result;
}
}();
const auto path = QString(rootPath + _item->_file);
const auto parentPath = path.left(path.lastIndexOf('/'));
const auto path = _item->_file;
const auto slashPosition = path.lastIndexOf('/');
const auto parentPath = slashPosition >= 0 ? path.left(slashPosition) : QString();
SyncJournalFileRecord parentRec;
bool ok = propagator()->_journal->getFileRecord(parentPath, &parentRec);
@ -190,10 +191,11 @@ void PropagateUploadFileCommon::start()
}
const auto remoteParentPath = parentRec._e2eMangledName.isEmpty() ? parentPath : parentRec._e2eMangledName;
const auto absoluteRemoteParentPath = remoteParentPath.isEmpty() ? rootPath : rootPath + remoteParentPath + '/';
const auto account = propagator()->account();
if (!account->capabilities().clientSideEncryptionAvailable() ||
!account->e2e()->isFolderEncrypted(remoteParentPath + '/')) {
!account->e2e()->isFolderEncrypted(absoluteRemoteParentPath)) {
setupUnencryptedFile();
return;
}