diff --git a/src/common/vfs.h b/src/common/vfs.h index f4ea3d8fa..b7bd22098 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -190,7 +190,7 @@ public: * new placeholder shall supersede, for rename-replace actions with new downloads, * for example. */ - virtual void convertToPlaceholder( + virtual Result convertToPlaceholder( const QString &filename, const SyncFileItem &item, const QString &replacesFile = QString()) = 0; @@ -296,7 +296,7 @@ public: Result updateMetadata(const QString &, time_t, qint64, const QByteArray &) override { return {}; } Result createPlaceholder(const SyncFileItem &) override { return {}; } Result dehydratePlaceholder(const SyncFileItem &) override { return {}; } - void convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) override {} + Result convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) override { return {}; } bool needsMetadataUpdate(const SyncFileItem &) override { return false; } bool isDehydratedPlaceholder(const QString &) override { return false; } diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index f26dad05c..c576c93df 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -737,7 +737,9 @@ QString OwncloudPropagator::adjustRenamedPath(const QString &original) const bool OwncloudPropagator::updateMetadata(const SyncFileItem &item, const QString &localFolderPath, SyncJournalDb &journal, Vfs &vfs) { QString fsPath = localFolderPath + item.destination(); - vfs.convertToPlaceholder(fsPath, item); + if (!vfs.convertToPlaceholder(fsPath, item)) { + return false; + } auto record = item.toSyncJournalFileRecordWithInode(fsPath); return journal.setFileRecord(record); } diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 161b191df..06c0c6337 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -964,7 +964,11 @@ void PropagateDownloadFile::downloadFinished() preserveGroupOwnership(_tmpFile.fileName(), existingFile); // Make the file a hydrated placeholder if possible - propagator()->syncOptions()._vfs->convertToPlaceholder(_tmpFile.fileName(), *_item, fn); + const auto result = propagator()->syncOptions()._vfs->convertToPlaceholder(_tmpFile.fileName(), *_item, fn); + if (!result) { + done(SyncFileItem::NormalError, result.error()); + return; + } } // Apply the remote permissions diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 9c2dd8edc..7d6ae74d3 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -346,7 +346,12 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) // Ensure it's a placeholder file on disk if (item->_type == ItemTypeFile) { - _syncOptions._vfs->convertToPlaceholder(filePath, *item); + const auto result = _syncOptions._vfs->convertToPlaceholder(filePath, *item); + if (!result) { + item->_instruction = CSYNC_INSTRUCTION_ERROR; + item->_errorString = tr("Could not update file : %1").arg(result.error()); + return; + } } // Update on-disk virtual file metadata diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index 4a73ad968..7a5da1e0e 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -149,16 +149,16 @@ Result VfsCfApi::dehydratePlaceholder(const SyncFileItem &item) return {}; } -void VfsCfApi::convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile) +Result VfsCfApi::convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile) { const auto localPath = QDir::toNativeSeparators(filename); const auto replacesPath = QDir::toNativeSeparators(replacesFile); const auto handle = cfapi::handleForPath(localPath); if (cfapi::findPlaceholderInfo(handle)) { - cfapi::updatePlaceholderInfo(handle, item._modtime, item._size, item._fileId, replacesPath); + return cfapi::updatePlaceholderInfo(handle, item._modtime, item._size, item._fileId, replacesPath); } else { - cfapi::convertToPlaceholder(handle, item._modtime, item._size, item._fileId, replacesPath); + return cfapi::convertToPlaceholder(handle, item._modtime, item._size, item._fileId, replacesPath); } } diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.h b/src/libsync/vfs/cfapi/vfs_cfapi.h index e4a4d0074..96dda52d4 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.h +++ b/src/libsync/vfs/cfapi/vfs_cfapi.h @@ -43,7 +43,7 @@ public: Result createPlaceholder(const SyncFileItem &item) override; Result dehydratePlaceholder(const SyncFileItem &item) override; - void convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile) override; + Result convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile) override; bool needsMetadataUpdate(const SyncFileItem &) override; bool isDehydratedPlaceholder(const QString &filePath) override; diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp index 40a7519a7..f3858e8a2 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.cpp +++ b/src/libsync/vfs/suffix/vfs_suffix.cpp @@ -122,9 +122,10 @@ Result VfsSuffix::dehydratePlaceholder(const SyncFileItem &item) return {}; } -void VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) +Result VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) { // Nothing necessary + return {}; } bool VfsSuffix::isDehydratedPlaceholder(const QString &filePath) diff --git a/src/libsync/vfs/suffix/vfs_suffix.h b/src/libsync/vfs/suffix/vfs_suffix.h index 3feca6ea0..4aa513c03 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.h +++ b/src/libsync/vfs/suffix/vfs_suffix.h @@ -41,7 +41,7 @@ public: Result createPlaceholder(const SyncFileItem &item) override; Result dehydratePlaceholder(const SyncFileItem &item) override; - void convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &) override; + Result convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &) override; bool needsMetadataUpdate(const SyncFileItem &) override { return false; } bool isDehydratedPlaceholder(const QString &filePath) override;