Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function getRoot() {
return $this->root;
}

protected function getGetUnjailedRoot(): string {
public function getGetUnjailedRoot(): string {
return $this->sourceRootInfo->getPath();
}

Expand Down
13 changes: 8 additions & 5 deletions lib/private/Files/Cache/Wrapper/CacheJail.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ public function __construct(
) {
parent::__construct($cache, $dependencies);

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

Expand All @@ -50,7 +53,7 @@ protected function getRoot() {
*
* @return string
*/
protected function getGetUnjailedRoot() {
public function getGetUnjailedRoot() {
return $this->unjailedRoot;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/lib/Files/Cache/Wrapper/CacheJailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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;
Expand Down Expand Up @@ -252,4 +253,14 @@ public function testWatcherAfterInnerWatcher(): void {
$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());
}
}
Loading