]> source.dussan.org Git - nextcloud-server.git/commitdiff
optimize search post-processing for jail wrapper 33603/head
authorRobin Appelman <robin@icewind.nl>
Mon, 15 Aug 2022 18:52:12 +0000 (20:52 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 18 Aug 2022 11:39:36 +0000 (13:39 +0200)
don't both asking the wrapped cache if we know it's not in our jail anyway

Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Cache/Wrapper/CacheJail.php

index 7183a6c0d2a6daf37320fdce97365ca73f26cce7..2c8a5b4dbf082b2ed4a29e11baa754e21f1d765d 100644 (file)
@@ -324,11 +324,13 @@ class CacheJail extends CacheWrapper {
        }
 
        public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {
-               $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry);
-               if ($rawEntry) {
-                       $jailedPath = $this->getJailedPath($rawEntry->getPath());
-                       if ($jailedPath !== null) {
-                               return $this->formatCacheEntry(clone $rawEntry) ?: null;
+               if ($this->getGetUnjailedRoot() === '' || strpos($rawEntry->getPath(), $this->getGetUnjailedRoot()) === 0) {
+                       $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry);
+                       if ($rawEntry) {
+                               $jailedPath = $this->getJailedPath($rawEntry->getPath());
+                               if ($jailedPath !== null) {
+                                       return $this->formatCacheEntry(clone $rawEntry) ?: null;
+                               }
                        }
                }