Fix getDirectoryContent implementation for Jail wrapper

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/20725/head
Robin Appelman 6 years ago
parent 8d5404b750
commit 4e6d3d1880
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
  1. 4
      lib/private/Files/ObjectStore/SwiftFactory.php
  2. 2
      lib/private/Files/Storage/Wrapper/Jail.php
  3. 15
      tests/lib/Files/Storage/Storage.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'];
}

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

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

Loading…
Cancel
Save