Fix getDirectoryContent implementation for Jail wrapper

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2020-04-29 16:34:41 +02:00
parent 8d5404b750
commit 4e6d3d1880
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
3 changed files with 18 additions and 3 deletions

View File

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

View File

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

View File

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