Merge pull request #260 from nextcloud/fix-versions-stable9
[stable9] check permissions before rollback
This commit is contained in:
commit
d52343fc4e
|
@ -325,6 +325,13 @@ class Storage {
|
||||||
$files_view = new View('/'. User::getUser().'/files');
|
$files_view = new View('/'. User::getUser().'/files');
|
||||||
$versionCreated = false;
|
$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
|
//first create a new version
|
||||||
$version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename);
|
$version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename);
|
||||||
if (!$users_view->file_exists($version)) {
|
if (!$users_view->file_exists($version)) {
|
||||||
|
@ -338,10 +345,9 @@ class Storage {
|
||||||
// This has to happen manually here since the file is manually copied below
|
// This has to happen manually here since the file is manually copied below
|
||||||
$oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
|
$oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
|
||||||
$oldFileInfo = $users_view->getFileInfo($fileToRestore);
|
$oldFileInfo = $users_view->getFileInfo($fileToRestore);
|
||||||
$newFileInfo = $files_view->getFileInfo($filename);
|
$cache = $fileInfo->getStorage()->getCache();
|
||||||
$cache = $newFileInfo->getStorage()->getCache();
|
|
||||||
$cache->update(
|
$cache->update(
|
||||||
$newFileInfo->getId(), [
|
$fileInfo->getId(), [
|
||||||
'encrypted' => $oldVersion,
|
'encrypted' => $oldVersion,
|
||||||
'encryptedVersion' => $oldVersion,
|
'encryptedVersion' => $oldVersion,
|
||||||
'size' => $oldFileInfo->getSize()
|
'size' => $oldFileInfo->getSize()
|
||||||
|
|
Loading…
Reference in New Issue