summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-06-05 16:22:03 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-06-05 16:22:03 +0200
commit9899e10a0411d161db1b4e1302690ac74c1ae72c (patch)
tree95b38c87e836bf9c41b606f0da11befe764bca52 /apps
parent85d1ca11d4f84645fa732e7a4792317cff1aaa47 (diff)
parentbd0b9a0fe0b233e395d01cc8eb79b84506c9323b (diff)
downloadnextcloud-server-9899e10a0411d161db1b4e1302690ac74c1ae72c.tar.gz
nextcloud-server-9899e10a0411d161db1b4e1302690ac74c1ae72c.zip
Merge pull request #16753 from owncloud/issue-16752-check-for-existing-user-in-expire-tasks
Check whether the user exists before trying to set up his file system
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/command/expire.php6
-rw-r--r--apps/files_trashbin/tests/command/expiretest.php34
-rw-r--r--apps/files_versions/command/expire.php6
-rw-r--r--apps/files_versions/tests/command/expiretest.php34
4 files changed, 80 insertions, 0 deletions
diff --git a/apps/files_trashbin/command/expire.php b/apps/files_trashbin/command/expire.php
index e617fa47c90..e7dd5c573c2 100644
--- a/apps/files_trashbin/command/expire.php
+++ b/apps/files_trashbin/command/expire.php
@@ -49,6 +49,12 @@ class Expire implements ICommand {
}
public function handle() {
+ $userManager = \OC::$server->getUserManager();
+ if (!$userManager->userExists($this->user)) {
+ // User has been deleted already
+ return;
+ }
+
\OC_Util::tearDownFS();
\OC_Util::setupFS($this->user);
Trashbin::expire($this->trashBinSize, $this->user);
diff --git a/apps/files_trashbin/tests/command/expiretest.php b/apps/files_trashbin/tests/command/expiretest.php
new file mode 100644
index 00000000000..a6a8a6d53a8
--- /dev/null
+++ b/apps/files_trashbin/tests/command/expiretest.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_Trashbin\Tests\Command;
+
+use OCA\Files_Trashbin\Command\Expire;
+use Test\TestCase;
+
+class ExpireTest extends TestCase {
+ public function testExpireNonExistingUser() {
+ $command = new Expire('test', 0);
+ $command->handle();
+
+ $this->assertTrue(true);
+ }
+}
diff --git a/apps/files_versions/command/expire.php b/apps/files_versions/command/expire.php
index 6cec9f4fac3..ec9aa3e80d3 100644
--- a/apps/files_versions/command/expire.php
+++ b/apps/files_versions/command/expire.php
@@ -50,6 +50,12 @@ class Expire implements ICommand {
public function handle() {
+ $userManager = \OC::$server->getUserManager();
+ if (!$userManager->userExists($this->user)) {
+ // User has been deleted already
+ return;
+ }
+
\OC_Util::setupFS($this->user);
Storage::expire($this->fileName, $this->versionsSize, $this->neededSpace);
\OC_Util::tearDownFS();
diff --git a/apps/files_versions/tests/command/expiretest.php b/apps/files_versions/tests/command/expiretest.php
new file mode 100644
index 00000000000..247fb99b767
--- /dev/null
+++ b/apps/files_versions/tests/command/expiretest.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_Versions\Tests\Command;
+
+use OCA\Files_Versions\Command\Expire;
+use Test\TestCase;
+
+class ExpireTest extends TestCase {
+ public function testExpireNonExistingUser() {
+ $command = new Expire('test', '');
+ $command->handle();
+
+ $this->assertTrue(true);
+ }
+}