diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 62aa980cd2..f0454c97fb 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -652,8 +652,11 @@ void Folder::slotWatchedPathChanged(const QStringView &path, const ChangeReason if (record.isValid() && !FileSystem::fileChanged(path.toString(), record._fileSize, record._modtime) && _vfs) { spurious = true; - if (auto pinState = _vfs->pinState(relativePath.toString())) { + qCDebug(lcFolder) << "PinState for" << relativePath << "is" << *pinState; + if (*pinState == PinState::Unspecified) { + spurious = false; + } if (*pinState == PinState::AlwaysLocal && record.isVirtualFile()) { spurious = false; } diff --git a/test/testsynccfapi.cpp b/test/testsynccfapi.cpp index d1ef2994e2..20f509cb64 100644 --- a/test/testsynccfapi.cpp +++ b/test/testsynccfapi.cpp @@ -1449,6 +1449,43 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + void testDetectSpuriousNotification() { +#if !defined Q_OS_WIN + QSKIP("not applicable"); +#endif + FakeFolder fakeFolder{FileInfo{}}; + auto vfs = setupVfs(fakeFolder); + + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + + const QString odpFile("odp/presentation.odp"); + const QString odtFile("odt/document.odt"); + fakeFolder.localModifier().mkdir("odp"); + fakeFolder.localModifier().insert(odpFile); + fakeFolder.localModifier().mkdir("odt"); + fakeFolder.localModifier().insert(odtFile); + + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + ItemCompletedSpy completeSpy(fakeFolder); + + QFile odp(fakeFolder.localPath() + odpFile); + QVERIFY(odp.open(QIODevice::ReadWrite)); + odp.write(odpFile.toLatin1(), qstrlen(odpFile.toLatin1())); + odp.close(); + QVERIFY(fakeFolder.syncOnce()); + QVERIFY(itemInstruction(completeSpy, odpFile, CSYNC_INSTRUCTION_SYNC)); + QCOMPARE(*vfs->pinState(odpFile), PinState::Unspecified); + + QFile odt(fakeFolder.localPath() + odtFile); + QVERIFY(odt.open(QIODevice::ReadWrite)); + odt.close(); + QVERIFY(fakeFolder.syncOnce()); + QVERIFY(itemInstruction(completeSpy, odtFile, CSYNC_INSTRUCTION_UPDATE_METADATA)); + QCOMPARE(*vfs->pinState(odtFile), PinState::Unspecified); + } }; QTEST_GUILESS_MAIN(TestSyncCfApi)