mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
Vfs: Enable propagating attributes on download
This commit is contained in:
parent
01f7bc7b49
commit
597cc60f52
4 changed files with 15 additions and 7 deletions
|
@ -146,8 +146,15 @@ public:
|
||||||
*
|
*
|
||||||
* Implementations must make sure that calling this function on a file that already
|
* Implementations must make sure that calling this function on a file that already
|
||||||
* is a placeholder is acceptable.
|
* 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.
|
/// Determine whether the file at the given absolute path is a dehydrated placeholder.
|
||||||
virtual bool isDehydratedPlaceholder(const QString &filePath) = 0;
|
virtual bool isDehydratedPlaceholder(const QString &filePath) = 0;
|
||||||
|
@ -234,7 +241,7 @@ public:
|
||||||
|
|
||||||
bool updateMetadata(const QString &, time_t, quint64, const QByteArray &, QString *) override { return true; }
|
bool updateMetadata(const QString &, time_t, quint64, const QByteArray &, QString *) override { return true; }
|
||||||
void createPlaceholder(const QString &, const SyncFileItem &) override {}
|
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 isDehydratedPlaceholder(const QString &) override { return false; }
|
||||||
bool statTypeVirtualFile(csync_file_stat_t *, void *) override { return false; }
|
bool statTypeVirtualFile(csync_file_stat_t *, void *) override { return false; }
|
||||||
|
|
|
@ -421,6 +421,7 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
|
||||||
if (_item->_type == ItemTypeVirtualFileDehydration) {
|
if (_item->_type == ItemTypeVirtualFileDehydration) {
|
||||||
_item->_type = ItemTypeVirtualFile;
|
_item->_type = ItemTypeVirtualFile;
|
||||||
// TODO: Could dehydrate without wiping the file entirely
|
// 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);
|
auto fn = propagator()->getFilePath(_item->_file);
|
||||||
qCDebug(lcPropagateDownload) << "dehydration: wiping base file" << fn;
|
qCDebug(lcPropagateDownload) << "dehydration: wiping base file" << fn;
|
||||||
propagator()->_journal->deleteFileRecord(_item->_file);
|
propagator()->_journal->deleteFileRecord(_item->_file);
|
||||||
|
@ -987,6 +988,9 @@ void PropagateDownloadFile::downloadFinished()
|
||||||
// Apply the remote permissions
|
// Apply the remote permissions
|
||||||
FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(), !_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite));
|
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;
|
QString error;
|
||||||
emit propagator()->touchedFile(fn);
|
emit propagator()->touchedFile(fn);
|
||||||
// The fileChanged() check is done above to generate better error messages.
|
// The fileChanged() check is done above to generate better error messages.
|
||||||
|
@ -1004,9 +1008,6 @@ void PropagateDownloadFile::downloadFinished()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the file a hydrated placeholder if possible
|
|
||||||
propagator()->syncOptions()._vfs->convertToPlaceholder(fn, *_item);
|
|
||||||
|
|
||||||
FileSystem::setFileHidden(fn, false);
|
FileSystem::setFileHidden(fn, false);
|
||||||
|
|
||||||
// Maybe we downloaded a newer version of the file than we thought we would...
|
// Maybe we downloaded a newer version of the file than we thought we would...
|
||||||
|
|
|
@ -70,7 +70,7 @@ void VfsSuffix::createPlaceholder(const QString &syncFolder, const SyncFileItem
|
||||||
FileSystem::setModTime(fn, item._modtime);
|
FileSystem::setModTime(fn, item._modtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &)
|
void VfsSuffix::convertToPlaceholder(const QString &, const SyncFileItem &, const QString &)
|
||||||
{
|
{
|
||||||
// Nothing necessary
|
// Nothing necessary
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
bool updateMetadata(const QString &filePath, time_t modtime, quint64 size, const QByteArray &fileId, QString *error) override;
|
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 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 isDehydratedPlaceholder(const QString &filePath) override;
|
||||||
bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) override;
|
bool statTypeVirtualFile(csync_file_stat_t *stat, void *stat_data) override;
|
||||||
|
|
Loading…
Reference in a new issue