Skip to content

Commit

Permalink
remove the enforcement of identical etag for a server side item MOVE
Browse files Browse the repository at this point in the history
orignally added by owncloud/client#6632

most probably a too strong assumption on the behavior of the Nextcloud
server

better check real item metadata like fileid, size or modification time

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien authored and backportbot[bot] committed Oct 17, 2024
1 parent f55cd4e commit 5751042
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,8 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it
done = true;
return;
}
if (!serverEntry.isDirectory && base._etag != serverEntry.etag) {
/* File with different etag, don't do a rename, but download the file again */
qCInfo(lcDisco, "file etag different, not a rename");
if (!serverEntry.isDirectory && (base._modtime != serverEntry.modtime || base._fileSize != serverEntry.size)) {
qCInfo(lcDisco, "file metadata different, forcing a download of the new file");
done = true;
return;
}
Expand Down
32 changes: 0 additions & 32 deletions test/testsyncmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,38 +741,6 @@ private slots:
}
}

// https://github.com/owncloud/client/issues/6629#issuecomment-402450691
// When a file is moved and the server mtime was not in sync, the local mtime should be kept
void testMoveAndMTimeChange()
{
FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
OperationCounter counter;
fakeFolder.setServerOverride(counter.functor());

// Changing the mtime on the server (without invalidating the etag)
fakeFolder.remoteModifier().find("A/a1")->lastModified = QDateTime::currentDateTimeUtc().addSecs(-50000);
fakeFolder.remoteModifier().find("A/a2")->lastModified = QDateTime::currentDateTimeUtc().addSecs(-40000);

// Move a few files
fakeFolder.remoteModifier().rename("A/a1", "A/a1_server_renamed");
fakeFolder.localModifier().rename("A/a2", "A/a2_local_renamed");

QVERIFY(fakeFolder.syncOnce());
QCOMPARE(counter.nGET, 0);
QCOMPARE(counter.nPUT, 0);
QCOMPARE(counter.nMOVE, 1);
QCOMPARE(counter.nDELETE, 0);

// Another sync should do nothing
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(counter.nGET, 0);
QCOMPARE(counter.nPUT, 0);
QCOMPARE(counter.nMOVE, 1);
QCOMPARE(counter.nDELETE, 0);

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

// Test for https://github.com/owncloud/client/issues/6694
void testInvertFolderHierarchy()
{
Expand Down

0 comments on commit 5751042

Please sign in to comment.