Merge pull request #3246 from nextcloud/bugfix/vfs-allow-dyhadration-of-readonly-files

VFS. Allow dehydartion of readonly files. Preserve 'readonly' flag when creating a placeholder.
This commit is contained in:
allexzander 2021-05-06 09:26:17 +03:00 committed by GitHub
commit 539b45a346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -427,6 +427,12 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
}
propagator()->_journal->deleteFileRecord(_item->_originalFile);
updateMetadata(false);
if (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)) {
// make sure ReadOnly flag is preserved for placeholder, similarly to regular files
FileSystem::setFileReadOnly(propagator()->fullLocalPath(_item->_file), true);
}
return;
}
if (vfs->mode() == Vfs::Off && _item->_type == ItemTypeVirtualFile) {
@ -446,6 +452,12 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
return;
}
updateMetadata(false);
if (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)) {
// make sure ReadOnly flag is preserved for placeholder, similarly to regular files
FileSystem::setFileReadOnly(propagator()->fullLocalPath(_item->_file), true);
}
return;
}

View File

@ -129,7 +129,7 @@ Result<void, QString> VfsCfApi::dehydratePlaceholder(const SyncFileItem &item)
{
const auto previousPin = pinState(item._file);
if (!QFile::remove(_setupParams.filesystemPath + item._file)) {
if (!FileSystem::remove(_setupParams.filesystemPath + item._file)) {
return QStringLiteral("Couldn't remove %1 to fulfill dehydration").arg(item._file);
}