Vfs: Hydrating a virtual is SYNC not NEW #7101
authorChristian Kamm <mail@ckamm.de>
Mon, 25 Mar 2019 09:53:13 +0000 (10:53 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:45 +0000 (10:58 +0100)
Previously it'd be NEW(ItemTypeFile), but now it has changed to be
SYNC(ItemTypeVirtualFileDownload) which allows better classification.

src/gui/folder.cpp
src/libsync/discovery.cpp
src/libsync/propagatedownload.cpp
test/testsyncvirtualfiles.cpp

index e2e52b530001b846fa35933e3f0eae82ae1c17de..633cc92099fd6aa58e897d13198d59f314ca6e35 100644 (file)
@@ -420,9 +420,9 @@ void Folder::createGuiLog(const QString &filename, LogStatus status, int count,
             break;
         case LogStatusNew:
             if (count > 1) {
-                text = tr("%1 and %n other file(s) are new.", "", count - 1).arg(file);
+                text = tr("%1 and %n other file(s) have been added.", "", count - 1).arg(file);
             } else {
-                text = tr("%1 is new.", "%1 names a file.").arg(file);
+                text = tr("%1 has been added.", "%1 names a file.").arg(file);
             }
             break;
         case LogStatusUpdated:
index 6f4810aefc98e2711e982fbd4f00dab26af21e31..91c8b689578bbd8fd29d03b90e6679171a6d90a2 100644 (file)
@@ -332,7 +332,7 @@ void ProcessDirectoryJob::processFile(PathTuple path,
             || localEntry.type == ItemTypeVirtualFileDownload)
         && (localEntry.isValid() || _queryLocal == ParentNotChanged)) {
         item->_direction = SyncFileItem::Down;
-        item->_instruction = CSYNC_INSTRUCTION_NEW;
+        item->_instruction = CSYNC_INSTRUCTION_SYNC;
         item->_type = ItemTypeVirtualFileDownload;
     }
 
@@ -381,7 +381,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(
             // The above check for the localEntry existing is important. Otherwise it breaks
             // the case where a file is moved and simultaneously tagged for download in the db.
             item->_direction = SyncFileItem::Down;
-            item->_instruction = CSYNC_INSTRUCTION_NEW;
+            item->_instruction = CSYNC_INSTRUCTION_SYNC;
             item->_type = ItemTypeVirtualFileDownload;
         } else if (dbEntry._etag != serverEntry.etag) {
             item->_direction = SyncFileItem::Down;
index 12677cb3d6a575ff79ce1f24e74427b9672f3854..3e9662cefbbdf23809bfc938cff70f767e140c8d 100644 (file)
@@ -1020,9 +1020,6 @@ void PropagateDownloadFile::downloadFinished()
         propagator()->_journal->setConflictRecord(_conflictRecord);
 
     if (_item->_type == ItemTypeVirtualFileDownload) {
-        // A downloaded virtual file becomes normal
-        _item->_type = ItemTypeFile;
-
         // If the virtual file used to have a different name and db
         // entry, wipe both now.
         auto vfs = propagator()->syncOptions()._vfs;
index 4bd21aabc903f6f02c35161fafc0d784b4bcbecd..69c5a4038ac644c53dea670108bbe71657872d36 100644 (file)
@@ -356,9 +356,11 @@ private slots:
         fakeFolder.localModifier().insert("A/a6");
         fakeFolder.localModifier().remove("A/a6.nextcloud");
         QVERIFY(fakeFolder.syncOnce());
-        QVERIFY(itemInstruction(completeSpy, "A/a1", CSYNC_INSTRUCTION_NEW));
+        QVERIFY(itemInstruction(completeSpy, "A/a1", CSYNC_INSTRUCTION_SYNC));
+        QCOMPARE(findItem(completeSpy, "A/a1")->_type, ItemTypeVirtualFileDownload);
         QVERIFY(itemInstruction(completeSpy, "A/a1.nextcloud", CSYNC_INSTRUCTION_NONE));
-        QVERIFY(itemInstruction(completeSpy, "A/a2", CSYNC_INSTRUCTION_NEW));
+        QVERIFY(itemInstruction(completeSpy, "A/a2", CSYNC_INSTRUCTION_SYNC));
+        QCOMPARE(findItem(completeSpy, "A/a2")->_type, ItemTypeVirtualFileDownload);
         QVERIFY(itemInstruction(completeSpy, "A/a2.nextcloud", CSYNC_INSTRUCTION_NONE));
         QVERIFY(itemInstruction(completeSpy, "A/a3.nextcloud", CSYNC_INSTRUCTION_REMOVE));
         QVERIFY(itemInstruction(completeSpy, "A/a4m", CSYNC_INSTRUCTION_NEW));
@@ -405,7 +407,7 @@ private slots:
         triggerDownload(fakeFolder, "A/a1");
         fakeFolder.serverErrorPaths().append("A/a1", 500);
         QVERIFY(!fakeFolder.syncOnce());
-        QVERIFY(itemInstruction(completeSpy, "A/a1", CSYNC_INSTRUCTION_NEW));
+        QVERIFY(itemInstruction(completeSpy, "A/a1", CSYNC_INSTRUCTION_SYNC));
         QVERIFY(itemInstruction(completeSpy, "A/a1.nextcloud", CSYNC_INSTRUCTION_NONE));
         QVERIFY(fakeFolder.currentLocalState().find("A/a1.nextcloud"));
         QVERIFY(!fakeFolder.currentLocalState().find("A/a1"));
@@ -415,7 +417,7 @@ private slots:
 
         fakeFolder.serverErrorPaths().clear();
         QVERIFY(fakeFolder.syncOnce());
-        QVERIFY(itemInstruction(completeSpy, "A/a1", CSYNC_INSTRUCTION_NEW));
+        QVERIFY(itemInstruction(completeSpy, "A/a1", CSYNC_INSTRUCTION_SYNC));
         QVERIFY(itemInstruction(completeSpy, "A/a1.nextcloud", CSYNC_INSTRUCTION_NONE));
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
         QCOMPARE(dbRecord(fakeFolder, "A/a1")._type, ItemTypeFile);
@@ -622,7 +624,8 @@ private slots:
         QVERIFY(itemInstruction(completeSpy, "renamed2.nextcloud", CSYNC_INSTRUCTION_RENAME));
         QVERIFY(dbRecord(fakeFolder, "renamed2.nextcloud")._type == ItemTypeVirtualFile);
 
-        QVERIFY(itemInstruction(completeSpy, "file3", CSYNC_INSTRUCTION_NEW));
+        QVERIFY(itemInstruction(completeSpy, "file3", CSYNC_INSTRUCTION_SYNC));
+        QVERIFY(dbRecord(fakeFolder, "file3")._type == ItemTypeFile);
         cleanup();
 
         // Test rename while adding/removing vfs suffix