summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-06-30 17:15:28 +0200
committerGitHub <noreply@github.com>2016-06-30 17:15:28 +0200
commitd52343fc4e28af8c22b8fd0af1d7488ab56cb736 (patch)
tree54868cd5ff2599a2d7449adc255d2a754facc976
parent912f07e2a978a4d63c4bb9061ad097296cf7fb2f (diff)
parent1208953ba1d4d55a18a639846bbcdd66a2d5bc5e (diff)
downloadnextcloud-server-d52343fc4e28af8c22b8fd0af1d7488ab56cb736.tar.gz
nextcloud-server-d52343fc4e28af8c22b8fd0af1d7488ab56cb736.zip
Merge pull request #260 from nextcloud/fix-versions-stable9
[stable9] check permissions before rollback
-rw-r--r--apps/files_versions/lib/storage.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 1062f49cf69..cf99f62b832 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -78,7 +78,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;
@@ -325,6 +325,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)) {
@@ -338,10 +345,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()
@@ -681,7 +687,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)) {