]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: get source file before moving the cache item in objectstore moveFromStorage
authorRobin Appelman <robin@icewind.nl>
Wed, 18 Sep 2024 09:13:20 +0000 (11:13 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 19 Sep 2024 15:44:27 +0000 (17:44 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/ObjectStore/ObjectStoreStorage.php

index 8b770ee19c5e59003d75fc411e82c855b25b55a9..d57b2d857773be412b0f7a126d9a8583f111ab16 100644 (file)
@@ -628,10 +628,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);