diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index e8d5fcb490a5b..c6700932779ce 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -55,10 +55,13 @@ public function __construct( parent::__construct($cache, $dependencies); $this->root = $root; - if ($cache instanceof CacheJail) { - $this->unjailedRoot = $cache->getSourcePath($root); - } else { - $this->unjailedRoot = $root; + $this->unjailedRoot = $root; + $parent = $cache; + while ($parent instanceof CacheWrapper) { + if ($parent instanceof CacheJail) { + $this->unjailedRoot = $parent->getSourcePath($this->unjailedRoot); + } + $parent = $parent->getCache(); } } @@ -71,7 +74,7 @@ protected function getRoot() { * * @return string */ - protected function getGetUnjailedRoot() { + public function getGetUnjailedRoot() { return $this->unjailedRoot; } diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php index 4f8bd8945c69a..0472ccec7bba1 100644 --- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php +++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php @@ -9,6 +9,7 @@ namespace Test\Files\Cache\Wrapper; use OC\Files\Cache\Wrapper\CacheJail; +use OC\Files\Cache\Wrapper\CacheWrapper; use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchQuery; use OC\Files\Storage\Wrapper\Jail; @@ -253,4 +254,14 @@ public function testWatcherAfterInnerWatcher() { $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']); $this->assertTrue($this->cache->inCache('bar')); } + + public function testUnJailedRoot(): void { + $jail1 = new CacheJail($this->sourceCache, 'foo'); + $jail2 = new CacheJail($jail1, 'bar'); + $this->assertEquals('foo/bar', $jail2->getGetUnjailedRoot()); + + $middleWrapper = new CacheWrapper($jail1); + $jail3 = new CacheJail($middleWrapper, 'bar'); + $this->assertEquals('foo/bar', $jail3->getGetUnjailedRoot()); + } }