diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-07-07 11:29:46 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-07-07 11:29:46 +0200 |
commit | ba16fd0d337fa26114f55086198979d147a298c1 (patch) | |
tree | 39111cec77d17d5eeb60bd1b609e7a8419310459 /apps/files_versions/lib/Storage.php | |
parent | 5ace43f43895cba4b398367e10731f92450d7da2 (diff) | |
parent | ed28885d73181e61c06802639910014e8a265e42 (diff) | |
download | nextcloud-server-ba16fd0d337fa26114f55086198979d147a298c1.tar.gz nextcloud-server-ba16fd0d337fa26114f55086198979d147a298c1.zip |
Merge branch 'master' into sync-master
Diffstat (limited to 'apps/files_versions/lib/Storage.php')
-rw-r--r-- | apps/files_versions/lib/Storage.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 5857b064699..cd4830d5469 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; @@ -313,6 +313,7 @@ class Storage { * * @param string $file file name * @param int $revision revision timestamp + * @return bool */ public static function rollback($file, $revision) { @@ -323,15 +324,19 @@ class Storage { if ($uid === null || trim($filename, '/') === '') { return false; } + $users_view = new View('/'.$uid); $files_view = new View('/'. User::getUser().'/files'); - if (!$files_view->isUpdatable($filename)) { + $versionCreated = false; + + $fileInfo = $files_view->getFileInfo($file); + + // check if user has the permissions to revert a version + if (!$fileInfo->isUpdateable()) { return false; } - $versionCreated = false; - //first create a new version $version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename); if (!$users_view->file_exists($version)) { @@ -345,10 +350,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() @@ -688,7 +692,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)) { |