diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2019-10-30 15:16:32 +0300 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-15 12:59:03 +0300 |
commit | 66f7b271211955f984dc81a64926385e12940096 (patch) | |
tree | 344609c50ef7bb75b77d93fc0c8bc7601373c7e5 /src/common | |
parent | 9807285abdc6599f2ec31a638d178231dd61653e (diff) |
VFS: Do not overwrite existing files by placeholder
For issue #7557 and #7556
Note: this change the API of the VFS plugin, so the VFS plugin needs small
adaptations
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/result.h | 12 | ||||
-rw-r--r-- | src/common/vfs.h | 14 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/common/result.h b/src/common/result.h index 61805982e..579914f5c 100644 --- a/src/common/result.h +++ b/src/common/result.h @@ -129,6 +129,18 @@ public: }; namespace detail { + struct NoResultData{}; +} + +template <typename Error> +class Result<void, Error> : public Result<detail::NoResultData, Error> +{ +public: + using Result<detail::NoResultData, Error>::Result; + Result() : Result(detail::NoResultData{}) {} +}; + +namespace detail { struct OptionalNoErrorData{}; } diff --git a/src/common/vfs.h b/src/common/vfs.h index ca28b631b..669e3f5b6 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -151,20 +151,18 @@ public: * * If the remote metadata changes, the local placeholder's metadata should possibly * change as well. - * - * Returning false and setting error indicates an error. */ - virtual bool updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId, QString *error) = 0; + virtual Result<void, QString> updateMetadata(const QString &filePath, time_t modtime, qint64 size, const QByteArray &fileId) = 0; /// Create a new dehydrated placeholder. Called from PropagateDownload. - virtual void createPlaceholder(const SyncFileItem &item) = 0; + virtual Result<void, QString> createPlaceholder(const SyncFileItem &item) = 0; /** Convert a hydrated placeholder to a dehydrated one. Called from PropagateDownlaod. * * This is different from delete+create because preserving some file metadata * (like pin states) may be essential for some vfs plugins. */ - virtual void dehydratePlaceholder(const SyncFileItem &item) = 0; + virtual Result<void, QString> dehydratePlaceholder(const SyncFileItem &item) = 0; /** Discovery hook: even unchanged files may need UPDATE_METADATA. * @@ -289,9 +287,9 @@ public: bool socketApiPinStateActionsShown() const override { return false; } bool isHydrating() const override { return false; } - bool updateMetadata(const QString &, time_t, qint64, const QByteArray &, QString *) override { return true; } - void createPlaceholder(const SyncFileItem &) override {} - void dehydratePlaceholder(const SyncFileItem &) override {} + Result<void, QString> updateMetadata(const QString &, time_t, qint64, const QByteArray &) override { return {}; } + Result<void, QString> createPlaceholder(const SyncFileItem &) override { return {}; } + Result<void, QString> dehydratePlaceholder(const SyncFileItem &) override { return {}; } void convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) override {} bool needsMetadataUpdate(const SyncFileItem &) override { return false; } |