]> source.dussan.org Git - nextcloud-server.git/commitdiff
Setup the filesystem in the expire command
authorRobin Appelman <icewind@owncloud.com>
Tue, 24 Mar 2015 09:19:54 +0000 (10:19 +0100)
committerRobin Appelman <icewind@owncloud.com>
Thu, 26 Mar 2015 16:07:02 +0000 (17:07 +0100)
apps/files_versions/command/expire.php
apps/files_versions/lib/storage.php
apps/files_versions/tests/versions.php

index 1036741c79100cb4c1a34ef2b69ab2470276998a..a934b0f715947dbf46b10244b63b1b8d8982b3cd 100644 (file)
@@ -11,6 +11,7 @@ namespace OCA\Files_Versions\Command;
 use OC\Command\FileAccess;
 use OCA\Files_Versions\Storage;
 use OCP\Command\ICommand;
+use OCP\IUser;
 
 class Expire implements ICommand {
        use FileAccess;
@@ -31,18 +32,26 @@ class Expire implements ICommand {
        private $neededSpace = 0;
 
        /**
+        * @var int
+        */
+       private $user;
+
+       /**
+        * @param IUser $user
         * @param string $fileName
         * @param int|null $versionsSize
         * @param int $neededSpace
         */
-       function __construct($fileName, $versionsSize = null, $neededSpace = 0) {
+       function __construct(IUser $user, $fileName, $versionsSize = null, $neededSpace = 0) {
+               $this->user = $user;
                $this->fileName = $fileName;
                $this->versionsSize = $versionsSize;
                $this->neededSpace = $neededSpace;
        }
 
 
-       public function handle(){
+       public function handle() {
+               $this->setupFS($this->user);
                Storage::expire($this->fileName, $this->versionsSize, $this->neededSpace);
        }
 }
index 40f6ad7e77db5ca4d2f41473307fea92ccde331c..34ed812f4bbde8244fd8dc350fb3646bb1fe36c1 100644 (file)
@@ -483,7 +483,7 @@ class Storage {
         * @param int $neededSpace
         */
        private static function scheduleExpire($fileName, $versionsSize = null, $neededSpace = 0) {
-               $command = new Expire($fileName, $versionsSize, $neededSpace);
+               $command = new Expire(\OC::$server->getUserSession()->getUser(), $fileName, $versionsSize, $neededSpace);
                \OC::$server->getCommandBus()->push($command);
        }
 
index cf0ffb320e2f1e17b4933bfabde3e9d3a875a74e..3690057355e68a7739433b492ab9bccf7ec92df2 100644 (file)
@@ -243,6 +243,8 @@ class Test_Files_Versioning extends \Test\TestCase {
                // execute rename hook of versions app
                \OC\Files\Filesystem::rename("test.txt", "test2.txt");
 
+               $this->runCommands();
+
                $this->assertFalse($this->rootView->file_exists($v1));
                $this->assertFalse($this->rootView->file_exists($v2));
 
@@ -285,8 +287,11 @@ class Test_Files_Versioning extends \Test\TestCase {
                // execute rename hook of versions app
                \OC\Files\Filesystem::rename('/folder1/test.txt', '/folder1/folder2/test.txt');
 
+
                self::loginHelper(self::TEST_VERSIONS_USER2);
 
+               $this->runCommands();
+
                $this->assertFalse($this->rootView->file_exists($v1));
                $this->assertFalse($this->rootView->file_exists($v2));
 
@@ -330,6 +335,8 @@ class Test_Files_Versioning extends \Test\TestCase {
 
                self::loginHelper(self::TEST_VERSIONS_USER);
 
+               $this->runCommands();
+
                $this->assertTrue($this->rootView->file_exists($v1));
                $this->assertTrue($this->rootView->file_exists($v2));
 
@@ -361,6 +368,8 @@ class Test_Files_Versioning extends \Test\TestCase {
                // execute copy hook of versions app
                \OC\Files\Filesystem::copy("test.txt", "test2.txt");
 
+               $this->runCommands();
+
                $this->assertTrue($this->rootView->file_exists($v1));
                $this->assertTrue($this->rootView->file_exists($v2));
 
@@ -414,7 +423,9 @@ class Test_Files_Versioning extends \Test\TestCase {
        public static function loginHelper($user, $create = false) {
 
                if ($create) {
-                       \OC_User::createUser($user, $user);
+                       $backend  = new \OC_User_Dummy();
+                       $backend->createUser($user, $user);
+                       \OC::$server->getUserManager()->registerBackend($backend);
                }
 
                \OC_Util::tearDownFS();