fix: only do cache copy in updater if the parent folder should be in cache

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2024-12-06 17:45:07 +01:00 committed by Côme Chilliet
parent 4fbeba3038
commit a4d2af5155

View file

@ -185,7 +185,15 @@ class Updater implements IUpdater {
*/
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);
}
});
}