aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2025-06-24 18:55:27 +0200
committerRobin Appelman <robin@icewind.nl>2025-06-24 19:02:20 +0200
commitb6766b5a7719ad6b1186e5e9670aa400784c98c5 (patch)
treebb1d98427e74b83fd7acf6ab6ea6e88864097754
parent82f43ba586ea7f3aa014794ac7838be5b9c6f7a8 (diff)
downloadnextcloud-server-artonge/feat/implement_custom_updater_for_object_storage.tar.gz
nextcloud-server-artonge/feat/implement_custom_updater_for_object_storage.zip
perf: also do updater optimization for deleting for object storeartonge/feat/implement_custom_updater_for_object_storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreStorage.php30
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreUpdater.php4
2 files changed, 30 insertions, 4 deletions
diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
index 2bfd736e11f..0f5d9ec6aa1 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php
@@ -153,7 +153,23 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
return false;
}
- return $this->rmObjects($entry);
+ $result = $this->rmObjects($entry);
+ if ($result) {
+ $this->removeFromCache($entry);
+ }
+ return $result;
+ }
+
+ /**
+ * Remove an item from cache and propagate the change to the parent folders.
+ *
+ * Similar logic to the `Updater` but done in-storage because we have the correct info to avoid expensive
+ * folder size calculations.
+ */
+ private function removeFromCache(ICacheEntry $entry): void {
+ $this->cache->remove($entry->getId());
+ $this->getUpdater()->correctParentStorageMtime($entry->getPath());
+ $this->propagator->propagateChange($entry->getPath(), time(), -$entry->getSize());
}
private function rmObjects(ICacheEntry $entry): bool {
@@ -180,15 +196,21 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
public function unlink(string $path): bool {
$path = $this->normalizePath($path);
$entry = $this->getCache()->get($path);
+ $result = false;
if ($entry instanceof ICacheEntry) {
if ($entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
- return $this->rmObjects($entry);
+ $result = $this->rmObjects($entry);
} else {
- return $this->rmObject($entry);
+ $result = $this->rmObject($entry);
}
}
- return false;
+
+ if ($result) {
+ $this->removeFromCache($entry);
+ }
+
+ return $result;
}
public function rmObject(ICacheEntry $entry): bool {
diff --git a/lib/private/Files/ObjectStore/ObjectStoreUpdater.php b/lib/private/Files/ObjectStore/ObjectStoreUpdater.php
index de78ad8f069..b35d883ae70 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreUpdater.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreUpdater.php
@@ -18,4 +18,8 @@ class ObjectStoreUpdater extends Updater {
public function update($path, $time = null, ?int $sizeDifference = null) {
// Noop
}
+
+ public function remove($path) {
+ // Noop
+ }
}