Merge pull request #20081 from owncloud/trashbin-loggedout

Fix trashbin wrapper when no user is loggedin
remotes/origin/fix_emit_scanFiles
Morris Jobke 2015-12-11 15:55:50 +07:00
commit 2fa97f69cb
2 changed files with 16 additions and 2 deletions

@ -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, '/');

@ -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');
}
}
}