aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-09-25 17:52:42 +0200
committerLouis <louis@chmn.me>2024-10-08 18:14:26 +0200
commit99d62bf368512f36615e110d7ef2d2191d5d3521 (patch)
tree350fc7ced243327bd4710830c71bd3422f2902b4 /lib/private
parent5d36da37176e1aa915e7e63a1a4689d5bd3e6990 (diff)
downloadnextcloud-server-99d62bf368512f36615e110d7ef2d2191d5d3521.tar.gz
nextcloud-server-99d62bf368512f36615e110d7ef2d2191d5d3521.zip
fix: preserve fileid when moving from objectstore to non-objectstore
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php13
-rw-r--r--lib/private/Files/Storage/Common.php20
2 files changed, 27 insertions, 6 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 7277c5b1e20..58dd8f6d2a4 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -69,6 +69,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
private $logger;
private bool $handleCopiesAsOwned;
+ private bool $preserveCacheItemsOnDelete = false;
/** @var bool */
protected $validateWrites = true;
@@ -204,7 +205,9 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
}
}
- $this->getCache()->remove($entry->getPath());
+ if (!$this->preserveCacheItemsOnDelete) {
+ $this->getCache()->remove($entry->getPath());
+ }
return true;
}
@@ -236,7 +239,9 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
}
//removing from cache is ok as it does not exist in the objectstore anyway
}
- $this->getCache()->remove($entry->getPath());
+ if (!$this->preserveCacheItemsOnDelete) {
+ $this->getCache()->remove($entry->getPath());
+ }
return true;
}
@@ -770,4 +775,8 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
$urn = $this->getURN($cacheEntry->getId());
$this->objectStore->abortMultipartUpload($urn, $writeToken);
}
+
+ public function setPreserveCacheOnDelete(bool $preserve) {
+ $this->preserveCacheItemsOnDelete = $preserve;
+ }
}
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index 87a4a810c0e..2e6fcd95099 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -48,6 +48,7 @@ use OC\Files\Cache\Scanner;
use OC\Files\Cache\Updater;
use OC\Files\Cache\Watcher;
use OC\Files\Filesystem;
+use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Files\EmptyFileNameException;
@@ -698,10 +699,21 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
if ($result) {
- if ($sourceStorage->is_dir($sourceInternalPath)) {
- $result = $sourceStorage->rmdir($sourceInternalPath);
- } else {
- $result = $sourceStorage->unlink($sourceInternalPath);
+ if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
+ /** @var ObjectStoreStorage $sourceStorage */
+ $sourceStorage->setPreserveCacheOnDelete(true);
+ }
+ try {
+ if ($sourceStorage->is_dir($sourceInternalPath)) {
+ $result = $sourceStorage->rmdir($sourceInternalPath);
+ } else {
+ $result = $sourceStorage->unlink($sourceInternalPath);
+ }
+ } finally {
+ if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
+ /** @var ObjectStoreStorage $sourceStorage */
+ $sourceStorage->setPreserveCacheOnDelete(false);
+ }
}
}
return $result;