From d8873c18a113c0604755b0aeac106f8d0ac77abe Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 29 Jan 2019 11:41:03 +0100 Subject: [PATCH] File watcher: Pin state attribute changes are valid notifications Previously they would be discarded since the file's mtime or size hadn't changed. --- src/common/syncjournalfilerecord.h | 1 + src/gui/folder.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common/syncjournalfilerecord.h b/src/common/syncjournalfilerecord.h index 064334928..3a8643fe8 100644 --- a/src/common/syncjournalfilerecord.h +++ b/src/common/syncjournalfilerecord.h @@ -53,6 +53,7 @@ public: QDateTime modDateTime() const { return Utility::qDateTimeFromTime_t(_modtime); } bool isDirectory() const { return _type == ItemTypeDirectory; } + bool isFile() const { return _type == ItemTypeFile || _type == ItemTypeVirtualFileDehydration; } bool isVirtualFile() const { return _type == ItemTypeVirtualFile || _type == ItemTypeVirtualFileDownload; } QByteArray _path; diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 916241778..c5bcbcd16 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -560,11 +560,23 @@ void Folder::slotWatchedPathChanged(const QString &path) } #endif - // Check that the mtime actually changed. + // Check that the mtime/size actually changed or there was + // an attribute change (pin state) that caused the notification + bool spurious = false; SyncJournalFileRecord record; if (_journal.getFileRecord(relativePathBytes, &record) && record.isValid() && !FileSystem::fileChanged(path, record._fileSize, record._modtime)) { + spurious = true; + + if (auto pinState = _vfs->pinState(relativePath.toString())) { + if (*pinState == PinState::AlwaysLocal && record.isVirtualFile()) + spurious = false; + if (*pinState == PinState::OnlineOnly && record.isFile()) + spurious = false; + } + } + if (spurious) { qCInfo(lcFolder) << "Ignoring spurious notification for file" << relativePath; return; // probably a spurious notification } -- 2.30.2