From 4e6d3d18805ba7713a65c461b627f8474d82f4f5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 29 Apr 2020 16:34:41 +0200 Subject: [PATCH] Fix getDirectoryContent implementation for Jail wrapper Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/SwiftFactory.php | 4 ++-- lib/private/Files/Storage/Wrapper/Jail.php | 2 +- tests/lib/Files/Storage/Storage.php | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/ObjectStore/SwiftFactory.php b/lib/private/Files/ObjectStore/SwiftFactory.php index 9857e1def85..0354fba638f 100644 --- a/lib/private/Files/ObjectStore/SwiftFactory.php +++ b/lib/private/Files/ObjectStore/SwiftFactory.php @@ -78,12 +78,12 @@ class SwiftFactory { * @throws StorageAuthException */ public function getCachedTokenId() { - if ( !isset($this->params['cachedToken']) ) { + if (!isset($this->params['cachedToken'])) { throw new StorageAuthException('Unauthenticated ObjectStore connection'); } // Is it V2 token? - if ( isset($this->params['cachedToken']['token']) ) { + if (isset($this->params['cachedToken']['token'])) { return $this->params['cachedToken']['token']['id']; } diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 929a4942562..7350c104ba8 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -541,6 +541,6 @@ class Jail extends Wrapper { } public function getDirectoryContent($directory): \Traversable { - return $this->getWrapperStorage()->getDirectoryContent($this->getJailedPath($directory)); + return $this->getWrapperStorage()->getDirectoryContent($this->getUnjailedPath($directory)); } } diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php index c37a8152989..ecc2bb50538 100644 --- a/tests/lib/Files/Storage/Storage.php +++ b/tests/lib/Files/Storage/Storage.php @@ -88,6 +88,21 @@ abstract class Storage extends \Test\TestCase { } $this->assertEquals([$directory], $content); + $content = iterator_to_array($this->instance->getDirectoryContent('/')); + + $this->assertCount(1, $content); + $dirEntry = $content[0]; + unset($dirEntry['scan_permissions']); + unset($dirEntry['etag']); + $this->assertEquals([ + 'name' => $directory, + 'mimetype' => $this->instance->getMimeType($directory), + 'mtime' => $this->instance->filemtime($directory), + 'size' => -1, + 'storage_mtime' => $this->instance->filemtime($directory), + 'permissions' => $this->instance->getPermissions($directory), + ], $dirEntry); + $this->assertFalse($this->instance->mkdir('/' . $directory)); //can't create existing folders $this->assertTrue($this->instance->rmdir('/' . $directory)); -- 2.39.5