*
* Implementations must make sure that calling this function on a file that already
* is a placeholder is acceptable.
+ *
+ * replacesFile can optionally contain a filesystem path to a placeholder that this
+ * new placeholder shall supersede, for rename-replace actions with new downloads,
+ * for example.
*/
- virtual void convertToPlaceholder(const QString &filename, const SyncFileItem &item) = 0;
+ virtual void convertToPlaceholder(
+ const QString &filename,
+ const SyncFileItem &item,
+ const QString &replacesFile = QString()) = 0;
/// Determine whether the file at the given absolute path is a dehydrated placeholder.
virtual bool isDehydratedPlaceholder(const QString &filePath) = 0;
bool updateMetadata(const QString &, time_t, quint64, const QByteArray &, QString *) override { return true; }
void createPlaceholder(const QString &, const SyncFileItem &) override {}
- void convertToPlaceholder(const QString &, const SyncFileItem &) override {}
+ void convertToPlaceholder(const QString &, const SyncFileItem &, const QString &) override {}
bool isDehydratedPlaceholder(const QString &) override { return false; }
bool statTypeVirtualFile(csync_file_stat_t *, void *) override { return false; }
if (_item->_type == ItemTypeVirtualFileDehydration) {
_item->_type = ItemTypeVirtualFile;
// TODO: Could dehydrate without wiping the file entirely
+ // TODO: That would be useful as it could preserve file attributes (pins)
auto fn = propagator()->getFilePath(_item->_file);
qCDebug(lcPropagateDownload) << "dehydration: wiping base file" << fn;
propagator()->_journal->deleteFileRecord(_item->_file);
// Apply the remote permissions
FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(), !_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite));
+ // Make the file a hydrated placeholder if possible
+ propagator()->syncOptions()._vfs->convertToPlaceholder(_tmpFile.fileName(), *_item, fn);
+
QString error;
emit propagator()->touchedFile(fn);
// The fileChanged() check is done above to generate better error messages.
return;
}
- // Make the file a hydrated placeholder if possible
- propagator()->syncOptions()._vfs->convertToPlaceholder(fn, *_item);
-
FileSystem::setFileHidden(fn, false);
// Maybe we downloaded a newer version of the file than we thought we would...
FileSystem::setModTime(fn, item._modtime);
}
-void VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &)
+void VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &, const QString &)
{
// Nothing necessary
}
bool updateMetadata(const QString &filePath, time_t modtime, quint64 size, const QByteArray &fileId, QString *error) override;
void createPlaceholder(const QString &syncFolder, const SyncFileItem &item) override;
- void convertToPlaceholder(const QString &filename, const SyncFileItem &item) override;
+ void convertToPlaceholder(const QString &filename, const SyncFileItem &item, const QString &) override;
bool isDehydratedPlaceholder(const QString &filePath) override;
bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) override;