diff --git a/src/common/vfs.h b/src/common/vfs.h index 060b5ec585fb2..80eb852d54504 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -187,7 +187,11 @@ class OCSYNC_EXPORT Vfs : public QObject * If the remote metadata changes, the local placeholder's metadata should possibly * change as well. */ - Q_REQUIRED_RESULT virtual Result updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId) = 0; + [[nodiscard]] virtual Result updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId) = 0; + + [[nodiscard]] virtual Result updatePlaceholderMarkInSync(const QString &filePath, const QByteArray &fileId) = 0; + + [[nodiscard]] virtual bool isPlaceHolderInSync(const QString &filePath) const = 0; /// Create a new dehydrated placeholder. Called from PropagateDownload. Q_REQUIRED_RESULT virtual Result createPlaceholder(const SyncFileItem &item) = 0; @@ -325,6 +329,8 @@ class OCSYNC_EXPORT VfsOff : public Vfs [[nodiscard]] bool isHydrating() const override { return false; } Result updateMetadata(const QString &, time_t, qint64, const QByteArray &) override { return {}; } + Result updatePlaceholderMarkInSync(const QString &filePath, const QByteArray &fileId) override {return {QString{}};} + bool isPlaceHolderInSync(const QString &filePath) const override { Q_UNUSED(filePath) return true; } Result createPlaceholder(const SyncFileItem &) override { return {}; } Result dehydratePlaceholder(const SyncFileItem &) override { return {}; } Result convertToPlaceholder(const QString &, const SyncFileItem &, const QString &, const UpdateMetadataTypes) override { return ConvertToPlaceholderResult::Ok; } diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 7b42535f22d8f..9fe31e2d74e4e 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -620,11 +620,27 @@ void Folder::slotWatchedPathChanged(const QString &path, ChangeReason reason) && !FileSystem::fileChanged(path, record._fileSize, record._modtime) && _vfs) { spurious = true; - if (auto pinState = _vfs->pinState(relativePath.toString())) { - if (*pinState == PinState::AlwaysLocal && record.isVirtualFile()) + const auto fileAvailability = _vfs->availability(relativePath.toString(), Vfs::AvailabilityRecursivity::NotRecursiveAvailability); + + qCInfo(lcFolder) << path + << "file size:" << record._fileSize << FileSystem::getSize(path) + << "file modtime:" << record._modtime << FileSystem::getModTime(path) + << "pin state:" << (*_vfs->pinState(relativePath.toString())) + << "virtual file:" << (fileAvailability && *fileAvailability == VfsItemAvailability::OnlineOnly ? "is virtual file" : "is plain old file"); + + if (const auto pinState = _vfs->pinState(relativePath.toString())) { + if (*pinState == PinState::AlwaysLocal && fileAvailability && *fileAvailability == VfsItemAvailability::OnlineOnly) { + spurious = false; + } + if (*pinState == PinState::OnlineOnly && (!fileAvailability || *fileAvailability != VfsItemAvailability::OnlineOnly)) { spurious = false; - if (*pinState == PinState::OnlineOnly && record.isFile()) + } + if (*pinState == PinState::OnlineOnly && fileAvailability && *fileAvailability == VfsItemAvailability::OnlineOnly) { + qCInfo(lcFolder) << "Not a spurious notification for file" << relativePath; + const auto result = _vfs->updateMetadata(path, FileSystem::getModTime(path), FileSystem::getSize(path), record._fileId); + Q_UNUSED(result) spurious = false; + } } else { spurious = false; } diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index 165e558cf0fe7..8b6b2321e0542 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -198,6 +198,11 @@ Result VfsCfApi::updateMetadata(const QString &filePath, time_t m } } +Result VfsCfApi::updatePlaceholderMarkInSync(const QString &filePath, const QByteArray &fileId) +{ + return cfapi::updatePlaceholderMarkInSync(filePath, fileId, {}); +} + Result VfsCfApi::createPlaceholder(const SyncFileItem &item) { Q_ASSERT(params().filesystemPath.endsWith('/')); diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.h b/src/libsync/vfs/cfapi/vfs_cfapi.h index 38e04e00ef446..9312e7973b561 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.h +++ b/src/libsync/vfs/cfapi/vfs_cfapi.h @@ -43,6 +43,10 @@ class VfsCfApi : public Vfs Result updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId) override; + Result updatePlaceholderMarkInSync(const QString &filePath, const QByteArray &fileId) override; + + bool isPlaceHolderInSync(const QString &filePath) const override; + Result createPlaceholder(const SyncFileItem &item) override; Result dehydratePlaceholder(const SyncFileItem &item) override; Result convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile, UpdateMetadataTypes updateType) override; diff --git a/src/libsync/vfs/suffix/vfs_suffix.h b/src/libsync/vfs/suffix/vfs_suffix.h index 85e39b1b00d92..ed8919f2d889d 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.h +++ b/src/libsync/vfs/suffix/vfs_suffix.h @@ -39,6 +39,8 @@ class VfsSuffix : public Vfs [[nodiscard]] bool isHydrating() const override; Result updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId) override; + Result updatePlaceholderMarkInSync(const QString &filePath, const QByteArray &fileId) override {return {QString{}};} + bool isPlaceHolderInSync(const QString &filePath) const override { Q_UNUSED(filePath) return true; } Result createPlaceholder(const SyncFileItem &item) override; Result dehydratePlaceholder(const SyncFileItem &item) override;