diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 1330b9a40fe6c..2945f83718d0e 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -634,23 +634,15 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t $this->moveFromStorage($sourceStorage, $child->getPath(), $targetInternalPath . '/' . $child->getName()); } $sourceStorage->rmdir($sourceInternalPath); - $sourceStorage->getCache()->remove($sourceInternalPath); } else { - $sourceStream = $sourceStorage->fopen($sourceInternalPath, 'r'); - if (!$sourceStream) { - return false; - } - // move the cache entry before the contents so that we have the correct fileid/urn for the target - $this->getCache()->moveFromCache($sourceCache, $sourceInternalPath, $targetInternalPath); - try { - $this->writeStream($targetInternalPath, $sourceStream, $sourceCacheEntry->getSize()); - } catch (\Exception $e) { - // restore the cache entry - $sourceCache->moveFromCache($this->getCache(), $targetInternalPath, $sourceInternalPath); - throw $e; - } $sourceStorage->unlink($sourceInternalPath); } + if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) { + /** @var ObjectStoreStorage $sourceStorage */ + $sourceStorage->setPreserveCacheOnDelete(false); + } + $this->getCache()->moveFromCache($sourceCache, $sourceInternalPath, $targetInternalPath); + return true; }