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
parent 7bc21d8a34
commit e7b882dd22
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB

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