Only check for external storage permissions when it is a folder.

Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
Camila Ayres 2024-06-24 18:58:02 +02:00
parent 0965deaa2f
commit e38a9f181a
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4

View file

@ -1348,7 +1348,6 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
const auto originalPath = base.path(); const auto originalPath = base.path();
// Function to gradually check conditions for accepting a move-candidate // Function to gradually check conditions for accepting a move-candidate
const auto isExternalStorage = base._remotePerm.hasPermission(RemotePermissions::IsMounted);
auto moveCheck = [&]() { auto moveCheck = [&]() {
if (!base.isValid()) { if (!base.isValid()) {
qCInfo(lcDisco) << "Not a move, no item in db with inode" << localEntry.inode; qCInfo(lcDisco) << "Not a move, no item in db with inode" << localEntry.inode;
@ -1397,19 +1396,6 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
return true; return true;
}; };
auto isExternalStorageRename = [&] {
OCC::SyncJournalFileRecord dbRecord;
const auto validRecord = _discoveryData->_statedb->getFileRecordByInode(localEntry.inode, &dbRecord);
qCInfo(lcDisco) << "File is saved in DB:" << validRecord;
qCInfo(lcDisco) << "File is in external storage:" << isExternalStorage;
if (validRecord && isExternalStorage) {
qCInfo(lcDisco) << "Try to process rename for path" << dbRecord._path << "and inode" << dbRecord._inode;
return true;
}
return false;
};
const auto isMove = moveCheck(); const auto isMove = moveCheck();
const auto isE2eeMove = isMove && (base.isE2eEncrypted() || isInsideEncryptedTree()); const auto isE2eeMove = isMove && (base.isE2eEncrypted() || isInsideEncryptedTree());
const auto isCfApiVfsMode = _discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() == Vfs::WindowsCfApi; const auto isCfApiVfsMode = _discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() == Vfs::WindowsCfApi;
@ -1423,9 +1409,8 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
item->_errorString = tr("Moved to invalid target, restoring"); item->_errorString = tr("Moved to invalid target, restoring");
} }
// If it's not a move/rename, it's just a local-NEW // If it's not a move it's just a local-NEW
if (!isExternalStorageRename()) { if (!isMove || (isE2eeMove && !isE2eeMoveOnlineOnlyItemWithCfApi)) {
if ((!isMove || (isE2eeMove && !isE2eeMoveOnlineOnlyItemWithCfApi))) {
if (base.isE2eEncrypted()) { if (base.isE2eEncrypted()) {
// renaming the encrypted folder is done via remove + re-upload hence we need to mark the newly created folder as encrypted // renaming the encrypted folder is done via remove + re-upload hence we need to mark the newly created folder as encrypted
// base is a record in the SyncJournal database that contains the data about the being-renamed folder with it's old name and encryption information // base is a record in the SyncJournal database that contains the data about the being-renamed folder with it's old name and encryption information
@ -1440,6 +1425,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
// Check local permission if we are allowed to put move the file here // Check local permission if we are allowed to put move the file here
// Technically we should use the permissions from the server, but we'll assume it is the same // Technically we should use the permissions from the server, but we'll assume it is the same
const auto serverHasMountRootProperty = _discoveryData->_account->serverHasMountRootProperty(); const auto serverHasMountRootProperty = _discoveryData->_account->serverHasMountRootProperty();
const auto isExternalStorage = base._remotePerm.hasPermission(RemotePermissions::IsMounted) && base.isDirectory();
const auto movePerms = checkMovePermissions(base._remotePerm, originalPath, item->isDirectory()); const auto movePerms = checkMovePermissions(base._remotePerm, originalPath, item->isDirectory());
if (!movePerms.sourceOk || !movePerms.destinationOk || (serverHasMountRootProperty && isExternalStorage) || isE2eeMoveOnlineOnlyItemWithCfApi) { if (!movePerms.sourceOk || !movePerms.destinationOk || (serverHasMountRootProperty && isExternalStorage) || isE2eeMoveOnlineOnlyItemWithCfApi) {
qCInfo(lcDisco) << "Move without permission to rename base file, " qCInfo(lcDisco) << "Move without permission to rename base file, "
@ -1481,7 +1467,6 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
} }
return; return;
} }
}
auto wasDeletedOnClient = _discoveryData->findAndCancelDeletedJob(originalPath); auto wasDeletedOnClient = _discoveryData->findAndCancelDeletedJob(originalPath);