vfs: Make some behaviors suffix-vfs specific
authorChristian Kamm <mail@ckamm.de>
Mon, 12 Nov 2018 11:23:49 +0000 (12:23 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:23 +0000 (10:58 +0100)
src/libsync/discovery.cpp

index c059c73932b7a58ec3285f9509f37607ff8b419a..8d6c5dcf926eee5949bc8edcb75dd927f8f50187 100644 (file)
@@ -619,8 +619,11 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
             qCInfo(lcDisco) << "Stale DB entry";
             _discoveryData->_statedb->deleteFileRecord(path._original, true);
             return;
-        } else if (dbEntry._type == ItemTypeVirtualFile) {
+        } else if (dbEntry._type == ItemTypeVirtualFile && isVfsWithSuffix()) {
             // If the virtual file is removed, recreate it.
+            // This is a precaution since the suffix files don't look like the real ones
+            // and we don't want users to accidentally delete server data because they
+            // might not expect that deleting the placeholder will have a remote effect.
             item->_instruction = CSYNC_INSTRUCTION_NEW;
             item->_direction = SyncFileItem::Down;
             item->_type = ItemTypeVirtualFile;
@@ -652,7 +655,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
             if (noServerEntry) {
                 item->_instruction = CSYNC_INSTRUCTION_REMOVE;
                 item->_direction = SyncFileItem::Down;
-            } else if (!dbEntry.isVirtualFile()) {
+            } else if (!dbEntry.isVirtualFile() && isVfsWithSuffix()) {
                 // If we find what looks to be a spurious "abc.owncloud" the base file "abc"
                 // might have been renamed to that. Make sure that the base file is not
                 // deleted from the server.
@@ -676,7 +679,11 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
                 item->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
                 item->_direction = SyncFileItem::Down; // Does not matter
             }
-        } else if (serverModified || dbEntry.isVirtualFile()) {
+        } else if (serverModified
+            // If a suffix-file changes we prefer to go into conflict mode - but in-place
+            // placeholders could be replaced by real files and should be a regular SYNC
+            // if there's no server change.
+            || (isVfsWithSuffix() && dbEntry.isVirtualFile())) {
             processFileConflict(item, path, localEntry, serverEntry, dbEntry);
         } else if (typeChange) {
             item->_instruction = CSYNC_INSTRUCTION_TYPE_CHANGE;