File watcher: Pin state attribute changes are valid notifications

Previously they would be discarded since the file's mtime or size hadn't
changed.
This commit is contained in:
Christian Kamm 2019-01-29 11:41:03 +01:00 committed by Kevin Ottens
parent 83a818678f
commit d8873c18a1
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 14 additions and 1 deletions

View file

@ -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;

View file

@ -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
}