Don't treat new folders in unpinned folders as files to dehydrate
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 26 Jan 2021 16:50:04 +0000 (17:50 +0100)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 26 Jan 2021 17:09:24 +0000 (17:09 +0000)
This would only happen if the parent of the newly created folder would
be explicitly set to online only, hence why it went under the radar
previously.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/vfs/cfapi/vfs_cfapi.cpp
test/testsynccfapi.cpp

index be0eb5f239ff9fc3e189ad4a4ed4c362b1ce7389..baeea51c12bb44f7963b946a625ccc20e72323e9 100644 (file)
@@ -187,8 +187,10 @@ bool VfsCfApi::statTypeVirtualFile(csync_file_stat_t *stat, void *statData)
     // It's a dir with a reparse point due to the placeholder info (hence the cloud tag)
     // if we don't remove the reparse point flag the discovery will end up thinking
     // it is a file... let's prevent it
-    if (isDirectory && hasReparsePoint && hasCloudTag) {
-        ffd->dwFileAttributes &= ~FILE_ATTRIBUTE_REPARSE_POINT;
+    if (isDirectory) {
+        if (hasReparsePoint && hasCloudTag) {
+            ffd->dwFileAttributes &= ~FILE_ATTRIBUTE_REPARSE_POINT;
+        }
         return false;
     } else if (isSparseFile && isPinned) {
         stat->type = ItemTypeVirtualFileDownload;
index 30634b1a2f956c3d568cbc6a022d1a00f823ed40..1632e56cba3d929bf530997e2093649b00a03128 100644 (file)
@@ -1067,6 +1067,33 @@ private slots:
         QCOMPARE(*vfs->pinState("onlinerenamed2/file1rename"), PinState::OnlineOnly);
     }
 
+    void testEmptyFolderInOnlineOnlyRoot()
+    {
+        FakeFolder fakeFolder{ FileInfo() };
+        setupVfs(fakeFolder);
+        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        ItemCompletedSpy completeSpy(fakeFolder);
+
+        auto cleanup = [&]() {
+            completeSpy.clear();
+        };
+        cleanup();
+
+        // OnlineOnly forced on the root
+        setPinState(fakeFolder.localPath(), PinState::OnlineOnly, cfapi::NoRecurse);
+
+        // No effect sync
+        QVERIFY(fakeFolder.syncOnce());
+        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        cleanup();
+
+        // Add an empty folder which should propagate
+        fakeFolder.localModifier().mkdir("A");
+        QVERIFY(fakeFolder.syncOnce());
+        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        cleanup();
+    }
+
     void testIncompatiblePins()
     {
         FakeFolder fakeFolder{ FileInfo() };