Merge pull request #253 from nextcloud/fix-versions
check permissions before rollback
This commit is contained in:
commit
5d0f5f175b
|
@ -324,6 +324,13 @@ class Storage {
|
|||
$files_view = new View('/'. User::getUser().'/files');
|
||||
$versionCreated = false;
|
||||
|
||||
$fileInfo = $files_view->getFileInfo($file);
|
||||
|
||||
// check if user has the permissions to revert a version
|
||||
if (!$fileInfo->isUpdateable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//first create a new version
|
||||
$version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename);
|
||||
if (!$users_view->file_exists($version)) {
|
||||
|
@ -337,10 +344,9 @@ class Storage {
|
|||
// This has to happen manually here since the file is manually copied below
|
||||
$oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
|
||||
$oldFileInfo = $users_view->getFileInfo($fileToRestore);
|
||||
$newFileInfo = $files_view->getFileInfo($filename);
|
||||
$cache = $newFileInfo->getStorage()->getCache();
|
||||
$cache = $fileInfo->getStorage()->getCache();
|
||||
$cache->update(
|
||||
$newFileInfo->getId(), [
|
||||
$fileInfo->getId(), [
|
||||
'encrypted' => $oldVersion,
|
||||
'encryptedVersion' => $oldVersion,
|
||||
'size' => $oldFileInfo->getSize()
|
||||
|
|
Loading…
Reference in New Issue