From ba1321adb9e12c18189abeaabedc23a9986d7c03 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 6 Dec 2024 17:45:07 +0100 Subject: [PATCH] fix: only do cache copy in updater if the parent folder should be in cache Signed-off-by: Robin Appelman --- lib/private/Files/Cache/Updater.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index a07741e1fd48f..069861198bb38 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -205,7 +205,15 @@ public function renameFromStorage(IStorage $sourceStorage, $source, $target) { */ public function copyFromStorage(IStorage $sourceStorage, string $source, string $target): void { $this->copyOrRenameFromStorage($sourceStorage, $source, $target, function (ICache $sourceCache, ICacheEntry $sourceInfo) use ($target) { - $this->cache->copyFromCache($sourceCache, $sourceInfo, $target); + $parent = dirname($target); + $parentInCache = $this->cache->inCache($parent); + if (!$parentInCache) { + $parentData = $this->scanner->scan($parent, Scanner::SCAN_SHALLOW, -1, false); + $parentInCache = $parentData !== null; + } + if ($parentInCache) { + $this->cache->copyFromCache($sourceCache, $sourceInfo, $target); + } }); }