mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #8111 from nextcloud/bugfix/pinstate
fix(PinState): don't trigger sync when file's PinState changed to Unspecified.
This commit is contained in:
commit
5e2fa24b2e
@ -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;
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user