From e6ad4e5b8a0e85d227236be20a1a23fd0757205d Mon Sep 17 00:00:00 2001 From: alex-z Date: Wed, 6 Dec 2023 12:27:40 +0100 Subject: [PATCH] Feature. Do not allow move of external storage mounted folders. Signed-off-by: alex-z --- src/libsync/discovery.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index f11b9ab907fe..de62a8075065 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1381,12 +1381,14 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // 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 - auto movePerms = checkMovePermissions(base._remotePerm, originalPath, item->isDirectory()); - if (!movePerms.sourceOk || !movePerms.destinationOk) { + const auto isExternalStorage = base._remotePerm.hasPermission(RemotePermissions::IsMounted); + const auto movePerms = checkMovePermissions(base._remotePerm, originalPath, item->isDirectory()); + if (!movePerms.sourceOk || !movePerms.destinationOk || isExternalStorage) { qCInfo(lcDisco) << "Move without permission to rename base file, " << "source:" << movePerms.sourceOk << ", target:" << movePerms.destinationOk - << ", targetNew:" << movePerms.destinationNewOk; + << ", targetNew:" << movePerms.destinationNewOk + << ", isExternalStorage:" << isExternalStorage; // If we can create the destination, do that. // Permission errors on the destination will be handled by checkPermissions later. @@ -1395,8 +1397,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // If the destination upload will work, we're fine with the source deletion. // If the source deletion can't work, checkPermissions will error. - if (movePerms.destinationNewOk) + // In case of external storage mounted folders we are never allowed to move/delete them + if (movePerms.destinationNewOk && !isExternalStorage) { return; + } // Here we know the new location can't be uploaded: must prevent the source delete. // Two cases: either the source item was already processed or not.