summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-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 4185fc6aec4..f91867b9f82 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 {
@@ -144,8 +145,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 64540505d22..e0592b26d92 100644
--- a/apps/files_trashbin/tests/storage.php
+++ b/apps/files_trashbin/tests/storage.php
@@ -523,4 +523,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');
+ }
+ }
}