Skip to content

Commit

Permalink
Merge pull request #5498 from nextcloud/bugfix/doNotRestoreVirtualFiles
Browse files Browse the repository at this point in the history
Bugfix/do not restore virtual files
  • Loading branch information
mgallien authored Mar 8, 2023
2 parents 68df7ca + cbf7ba7 commit 20e20a6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/libsync/propagateupload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ void PropagateUploadFileCommon::setupUnencryptedFile()
}

void PropagateUploadFileCommon::startUploadFile() {
Q_ASSERT(_item->_type != CSyncEnums::ItemTypeVirtualFile);

if (propagator()->_abortRequested) {
return;
}
Expand Down
8 changes: 5 additions & 3 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,11 @@ void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems)
syncItem->_instruction = CSYNC_INSTRUCTION_CONFLICT;
break;
case CSYNC_INSTRUCTION_REMOVE:
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << syncItem->_file;
syncItem->_instruction = CSYNC_INSTRUCTION_NEW;
syncItem->_direction = SyncFileItem::Up;
if (syncItem->_type != CSyncEnums::ItemTypeVirtualFile && syncItem->_type != CSyncEnums::ItemTypeVirtualFileDownload) {
qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << syncItem->_file;
syncItem->_instruction = CSYNC_INSTRUCTION_NEW;
syncItem->_direction = SyncFileItem::Up;
}
break;
case CSYNC_INSTRUCTION_RENAME:
case CSYNC_INSTRUCTION_NEW:
Expand Down
26 changes: 26 additions & 0 deletions test/testsynccfapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,32 @@ private slots:
CFVERIFY_VIRTUAL(fakeFolder, "online/sub/file1");
}
}

void testDataFingerPrint()
{
FakeFolder fakeFolder{ FileInfo{} };
setupVfs(fakeFolder);

fakeFolder.remoteModifier().mkdir("a");
fakeFolder.remoteModifier().mkdir("a/b");
fakeFolder.remoteModifier().mkdir("a/b/d");
fakeFolder.remoteModifier().insert("a/b/otherFile.txt");

//Server support finger print, but none is set.
fakeFolder.remoteModifier().extraDavProperties = "<oc:data-fingerprint></oc:data-fingerprint>";

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem);
QVERIFY(fakeFolder.syncOnce());

fakeFolder.remoteModifier().remove("a/b/otherFile.txt");
fakeFolder.remoteModifier().remove("a/b/d");
fakeFolder.remoteModifier().extraDavProperties = "<oc:data-fingerprint>initial_finger_print</oc:data-fingerprint>";

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem);
QVERIFY(fakeFolder.syncOnce());

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
};

QTEST_GUILESS_MAIN(TestSyncCfApi)
Expand Down
26 changes: 26 additions & 0 deletions test/testsyncvirtualfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,32 @@ private slots:
conflicts = findCaseClashConflicts(*fakeFolder.currentLocalState().find("a/b"));
QCOMPARE(conflicts.size(), shouldHaveCaseClashConflict ? 1 : 0);
}

void testDataFingerPrint()
{
FakeFolder fakeFolder{ FileInfo{} };
setupVfs(fakeFolder);

fakeFolder.remoteModifier().mkdir("a");
fakeFolder.remoteModifier().mkdir("a/b");
fakeFolder.remoteModifier().mkdir("a/b/d");
fakeFolder.remoteModifier().insert("a/b/otherFile.txt");

//Server support finger print, but none is set.
fakeFolder.remoteModifier().extraDavProperties = "<oc:data-fingerprint></oc:data-fingerprint>";

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem);
QVERIFY(fakeFolder.syncOnce());

fakeFolder.remoteModifier().remove("a/b/otherFile.txt");
fakeFolder.remoteModifier().remove("a/b/d");
fakeFolder.remoteModifier().extraDavProperties = "<oc:data-fingerprint>initial_finger_print</oc:data-fingerprint>";

fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem);
QVERIFY(fakeFolder.syncOnce());

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
};

QTEST_GUILESS_MAIN(TestSyncVirtualFiles)
Expand Down

0 comments on commit 20e20a6

Please sign in to comment.