File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed
lib/private/Files/Cache/Wrapper
tests/lib/Files/Cache/Wrapper Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ protected function getRoot() {
7676 return $ this ->root ;
7777 }
7878
79- protected function getGetUnjailedRoot () {
79+ public function getGetUnjailedRoot () {
8080 return $ this ->sourceRootInfo ->getPath ();
8181 }
8282
Original file line number Diff line number Diff line change @@ -35,10 +35,13 @@ public function __construct(
3535 parent ::__construct ($ cache , $ dependencies );
3636 $ this ->root = $ root ;
3737
38- if ($ cache instanceof CacheJail) {
39- $ this ->unjailedRoot = $ cache ->getSourcePath ($ root );
40- } else {
41- $ this ->unjailedRoot = $ root ;
38+ $ this ->unjailedRoot = $ root ;
39+ $ parent = $ cache ;
40+ while ($ parent instanceof CacheWrapper) {
41+ if ($ parent instanceof CacheJail) {
42+ $ this ->unjailedRoot = $ parent ->getSourcePath ($ this ->unjailedRoot );
43+ }
44+ $ parent = $ parent ->getCache ();
4245 }
4346 }
4447
@@ -51,7 +54,7 @@ protected function getRoot() {
5154 *
5255 * @return string
5356 */
54- protected function getGetUnjailedRoot () {
57+ public function getGetUnjailedRoot () {
5558 return $ this ->unjailedRoot ;
5659 }
5760
Original file line number Diff line number Diff line change 99namespace Test \Files \Cache \Wrapper ;
1010
1111use OC \Files \Cache \Wrapper \CacheJail ;
12+ use OC \Files \Cache \Wrapper \CacheWrapper ;
1213use OC \Files \Search \SearchComparison ;
1314use OC \Files \Search \SearchQuery ;
1415use OC \Files \Storage \Wrapper \Jail ;
@@ -253,4 +254,14 @@ public function testWatcherAfterInnerWatcher() {
253254 $ storage ->getWatcher ()->update ('bar ' , ['mimetype ' => 'text/plain ' ]);
254255 $ this ->assertTrue ($ this ->cache ->inCache ('bar ' ));
255256 }
257+
258+ public function testUnJailedRoot (): void {
259+ $ jail1 = new CacheJail ($ this ->sourceCache , 'foo ' );
260+ $ jail2 = new CacheJail ($ jail1 , 'bar ' );
261+ $ this ->assertEquals ('foo/bar ' , $ jail2 ->getGetUnjailedRoot ());
262+
263+ $ middleWrapper = new CacheWrapper ($ jail1 );
264+ $ jail3 = new CacheJail ($ middleWrapper , 'bar ' );
265+ $ this ->assertEquals ('foo/bar ' , $ jail3 ->getGetUnjailedRoot ());
266+ }
256267}
You can’t perform that action at this time.
0 commit comments