From 879fcc4253f74f4cf0d156866dd78c45caf39fac Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 18 Sep 2024 11:13:20 +0200 Subject: fix: get source file before moving the cache item in objectstore moveFromStorage Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/private/Files/ObjectStore') diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 1b55b4b3b44..c29eb6a63e3 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -607,10 +607,14 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil } $sourceStorage->rmdir($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, $sourceStorage->fopen($sourceInternalPath, 'r'), $sourceCacheEntry->getSize()); + $this->writeStream($targetInternalPath, $sourceStream, $sourceCacheEntry->getSize()); } catch (\Exception $e) { // restore the cache entry $sourceCache->moveFromCache($this->getCache(), $targetInternalPath, $sourceInternalPath); -- cgit v1.2.3