do not move to trash online only files/folders: going to fail
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 30 Oct 2024 15:37:42 +0000 (16:37 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 22 Nov 2024 08:50:08 +0000 (09:50 +0100)
ensure that even if move to trash is enabled, we do not erroneously try
to move online only files or folders to trash bin

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/propagatorjobs.cpp
src/libsync/vfs/cfapi/vfs_cfapi.cpp

index bcdf5a4697e695d6ef71d59e49148c511a80b5da..8b397f033e525e5ce85f523980f437a6a79d14b3 100644 (file)
@@ -117,7 +117,8 @@ void PropagateLocalRemove::start()
     }
 
     QString removeError;
-    if (_moveToTrash) {
+    const auto availability = propagator()->syncOptions()._vfs->availability(_item->_file, Vfs::AvailabilityRecursivity::RecursiveAvailability);
+    if (_moveToTrash && (!availability || (*availability != VfsItemAvailability::AllDehydrated && *availability != VfsItemAvailability::OnlineOnly && *availability != VfsItemAvailability::Mixed))) {
         if ((QDir(filename).exists() || FileSystem::fileExists(filename))
             && !FileSystem::moveToTrash(filename, &removeError)) {
             done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);
index 414caed1bf08caefabeb9373be8f5037df3763c3..7ae45a6d286a5770d14798ef37d51080f06b719b 100644 (file)
@@ -511,7 +511,7 @@ int VfsCfApi::finalizeHydrationJob(const QString &requestId)
 VfsCfApi::HydratationAndPinStates VfsCfApi::computeRecursiveHydrationAndPinStates(const QString &folderPath, const Optional<PinState> &basePinState)
 {
     Q_ASSERT(!folderPath.endsWith('/'));
-    const auto fullPath = params().filesystemPath + folderPath;
+    const auto fullPath = QString{params().filesystemPath + folderPath};
     QFileInfo info(params().filesystemPath + folderPath);
 
     if (!FileSystem::fileExists(fullPath)) {