]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix getDirectoryContent implementation for Jail wrapper 20725/head
authorRobin Appelman <robin@icewind.nl>
Wed, 29 Apr 2020 14:34:41 +0000 (16:34 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 30 Apr 2020 13:27:09 +0000 (15:27 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/ObjectStore/SwiftFactory.php
lib/private/Files/Storage/Wrapper/Jail.php
tests/lib/Files/Storage/Storage.php

index 9857e1def8570a776d72975cdf45bf68ee74384c..0354fba638f481735142336dd10a1617c4c62c90 100644 (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'];
                }
 
index 929a4942562ee5b1a235ed83777b049c209b1843..7350c104ba85543f3539c5de2d13569d379af453 100644 (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));
        }
 }
index c37a8152989d9147feecb1b0a2c8772c946ba7d7..ecc2bb505380a196579da325431d7b29ae2381fd 100644 (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));