]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix thrashbin wrapper when no user is loggedin
authorRobin Appelman <icewind@owncloud.com>
Tue, 27 Oct 2015 11:10:23 +0000 (12:10 +0100)
committerRobin Appelman <icewind@owncloud.com>
Fri, 11 Dec 2015 13:27:37 +0000 (14:27 +0100)
apps/files_trashbin/lib/storage.php
apps/files_trashbin/tests/storage.php

index 0e42df1e96738c201c84842e3b757736b751ee6b..becde5e635b2d886ab75c636af4063680ade5370 100644 (file)
@@ -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, '/');
index 3ebbbc3ec9db487546e281bf1592c1d8cd2a6300..abd0810f2124b4f7cd1a3e032dc53686fc9a9f8b 100644 (file)
@@ -531,4 +531,14 @@ 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();
+
+               $this->assertTrue($this->userView->file_exists('test.txt'));
+               $this->userView->unlink('test.txt');
+       }
 }