mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Handle errors in convertToPlaceholder
This commit is contained in:
parent
552427ffc3
commit
aadda32633
8 changed files with 23 additions and 11 deletions
|
@ -190,7 +190,7 @@ public:
|
|||
* new placeholder shall supersede, for rename-replace actions with new downloads,
|
||||
* for example.
|
||||
*/
|
||||
virtual void convertToPlaceholder(
|
||||
virtual Result<void, QString> convertToPlaceholder(
|
||||
const QString &filename,
|
||||
const SyncFileItem &item,
|
||||
const QString &replacesFile = QString()) = 0;
|
||||
|
@ -296,7 +296,7 @@ public:
|
|||
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 {}
|
||||
Result<void, QString> convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) override { return {}; }
|
||||
|
||||
bool needsMetadataUpdate(const SyncFileItem &) override { return false; }
|
||||
bool isDehydratedPlaceholder(const QString &) override { return false; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -149,16 +149,16 @@ Result<void, QString> VfsCfApi::dehydratePlaceholder(const SyncFileItem &item)
|
|||
return {};
|
||||
}
|
||||
|
||||
void VfsCfApi::convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile)
|
||||
Result<void, QString> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
Result<void, QString> createPlaceholder(const SyncFileItem &item) override;
|
||||
Result<void, QString> dehydratePlaceholder(const SyncFileItem &item) override;
|
||||
void convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile) override;
|
||||
Result<void, QString> convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &replacesFile) override;
|
||||
|
||||
bool needsMetadataUpdate(const SyncFileItem &) override;
|
||||
bool isDehydratedPlaceholder(const QString &filePath) override;
|
||||
|
|
|
@ -122,9 +122,10 @@ Result<void, QString> VfsSuffix::dehydratePlaceholder(const SyncFileItem &item)
|
|||
return {};
|
||||
}
|
||||
|
||||
void VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &, const QString &)
|
||||
Result<void, QString> VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &, const QString &)
|
||||
{
|
||||
// Nothing necessary
|
||||
return {};
|
||||
}
|
||||
|
||||
bool VfsSuffix::isDehydratedPlaceholder(const QString &filePath)
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
Result<void, QString> createPlaceholder(const SyncFileItem &item) override;
|
||||
Result<void, QString> dehydratePlaceholder(const SyncFileItem &item) override;
|
||||
void convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &) override;
|
||||
Result<void, QString> convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &) override;
|
||||
|
||||
bool needsMetadataUpdate(const SyncFileItem &) override { return false; }
|
||||
bool isDehydratedPlaceholder(const QString &filePath) override;
|
||||
|
|
Loading…
Reference in a new issue