diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-06-30 10:29:32 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-06-30 11:27:25 +0200 |
commit | 1b74cf72fbba0518f2b2a9b4ce5dcd6c606ec7ec (patch) | |
tree | 396fead1835cb68a99273b4afef66ee3dc071e08 /apps/files_versions/lib | |
parent | f7a69c765af490767fcd765f06086f7604fdbc43 (diff) | |
download | nextcloud-server-1b74cf72fbba0518f2b2a9b4ce5dcd6c606ec7ec.tar.gz nextcloud-server-1b74cf72fbba0518f2b2a9b4ce5dcd6c606ec7ec.zip |
check permissions before rollback
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r-- | apps/files_versions/lib/Storage.php | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 93f8b848ce8..b14210af7b1 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -77,7 +77,7 @@ class Storage { //until the end one version per week 6 => array('intervalEndsAfter' => -1, 'step' => 604800), ); - + /** @var \OCA\Files_Versions\AppInfo\Application */ private static $application; @@ -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() @@ -680,7 +686,7 @@ class Storage { public static function expire($filename) { $config = \OC::$server->getConfig(); $expiration = self::getExpiration(); - + if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) { if (!Filesystem::file_exists($filename)) { |