From 05b6db55c3da60366a05e00a7486309cdcdfc95e Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 16 Oct 2024 12:10:10 +0200 Subject: [PATCH] remove the enforcement of identical etag for a server side item MOVE orignally added by https://github.com/owncloud/client/pull/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 --- src/libsync/discovery.cpp | 5 ++--- test/testsyncmove.cpp | 32 -------------------------------- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index bb8daf4a5..90f26719e 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -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; } diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 1266fdef4..1475013cf 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -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() {