summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-03-24 10:19:54 +0100
committerRobin Appelman <icewind@owncloud.com>2015-03-26 17:07:02 +0100
commit176fba83eae36f39b987d1076fbad72be901add0 (patch)
tree85e60a392a6333ec9950a89f78fe69b0c5c59f96 /apps/files_versions
parentddd6a67d2a36791e2f921596f6c34436c4d5752d (diff)
downloadnextcloud-server-176fba83eae36f39b987d1076fbad72be901add0.tar.gz
nextcloud-server-176fba83eae36f39b987d1076fbad72be901add0.zip
Setup the filesystem in the expire command
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/command/expire.php13
-rw-r--r--apps/files_versions/lib/storage.php2
-rw-r--r--apps/files_versions/tests/versions.php13
3 files changed, 24 insertions, 4 deletions
diff --git a/apps/files_versions/command/expire.php b/apps/files_versions/command/expire.php
index 1036741c791..a934b0f7159 100644
--- a/apps/files_versions/command/expire.php
+++ b/apps/files_versions/command/expire.php
@@ -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);
}
}
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 40f6ad7e77d..34ed812f4bb 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -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);
}
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index cf0ffb320e2..3690057355e 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -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();