summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-12-11 15:55:50 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-12-11 15:55:50 +0100
commit2fa97f69cba4dd045d7f76a18a6f0f7bf8998a79 (patch)
tree7ef348cd3eb8ed6e8005c7333d798ffb352f3a9d
parent4f860b7e0a5284eee90fdd93d6ec733a1559a1eb (diff)
parent5b2957bad14adb7895f75dd27cafd2257e24e78a (diff)
downloadnextcloud-server-2fa97f69cba4dd045d7f76a18a6f0f7bf8998a79.tar.gz
nextcloud-server-2fa97f69cba4dd045d7f76a18a6f0f7bf8998a79.zip
Merge pull request #20081 from owncloud/trashbin-loggedout
Fix trashbin wrapper when no user is loggedin
-rw-r--r--apps/files_trashbin/lib/storage.php5
-rw-r--r--apps/files_trashbin/tests/storage.php13
2 files changed, 16 insertions, 2 deletions
diff --git a/apps/files_trashbin/lib/storage.php b/apps/files_trashbin/lib/storage.php
index 0e42df1e967..becde5e635b 100644
--- a/apps/files_trashbin/lib/storage.php
+++ b/apps/files_trashbin/lib/storage.php
@@ -26,6 +26,7 @@ namespace OCA\Files_Trashbin;
use OC\Files\Filesystem;
use OC\Files\Storage\Wrapper\Wrapper;
+use OC\Files\View;
use OCP\IUserManager;
class Storage extends Wrapper {
@@ -151,8 +152,8 @@ class Storage extends Wrapper {
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
$result = true;
- if (!isset($this->deletedFiles[$normalized])) {
- $view = Filesystem::getView();
+ $view = Filesystem::getView();
+ if (!isset($this->deletedFiles[$normalized]) && $view instanceof View) {
$this->deletedFiles[$normalized] = $normalized;
if ($filesPath = $view->getRelativePath($normalized)) {
$filesPath = trim($filesPath, '/');
diff --git a/apps/files_trashbin/tests/storage.php b/apps/files_trashbin/tests/storage.php
index 3ebbbc3ec9d..387bb20c6d4 100644
--- a/apps/files_trashbin/tests/storage.php
+++ b/apps/files_trashbin/tests/storage.php
@@ -531,4 +531,17 @@ class Storage extends \Test\TestCase {
['/schiesbn/', '/test.txt', false, false],
];
}
+
+ /**
+ * Test that deleting a file doesn't error when nobody is logged in
+ */
+ public function testSingleStorageDeleteFileLoggedOut() {
+ $this->logout();
+
+ if (!$this->userView->file_exists('test.txt')) {
+ $this->markTestSkipped('Skipping since the current home storage backend requires the user to logged in');
+ } else {
+ $this->userView->unlink('test.txt');
+ }
+ }
}