diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index 1e180e7993a4..2de0c8fe0679 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -171,13 +171,15 @@ public function rename($source, $target) { if ($sourceStorage && $targetStorage) { $targetCache = $targetStorage->getCache($sourceInternalPath); - if ($targetCache->inCache($targetInternalPath)) { - $targetCache->remove($targetInternalPath); - } - if ($sourceStorage === $targetStorage) { - $targetCache->move($sourceInternalPath, $targetInternalPath); - } else { - $targetCache->moveFromCache($sourceStorage->getCache(), $sourceInternalPath, $targetInternalPath); + if ($sourceStorage->getCache($sourceInternalPath)->inCache($sourceInternalPath)) { + if ($targetCache->inCache($targetInternalPath)) { + $targetCache->remove($targetInternalPath); + } + if ($sourceStorage === $targetStorage) { + $targetCache->move($sourceInternalPath, $targetInternalPath); + } else { + $targetCache->moveFromCache($sourceStorage->getCache(), $sourceInternalPath, $targetInternalPath); + } } if (pathinfo($sourceInternalPath, PATHINFO_EXTENSION) !== pathinfo($targetInternalPath, PATHINFO_EXTENSION)) {