summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-03-21 11:42:18 +0100
committerGitHub <noreply@github.com>2023-03-21 11:42:18 +0100
commitc60182065fa172d15867bff77bdc8a18ad0be709 (patch)
tree4b6528fba81e117b05e5a44a2ced8d4b9b2bfad0 /lib
parent71cdd96d20e86a980ee2aed6e8befe77e3a24264 (diff)
parent2830eeac7ea261e38cc8e03847c44a352733cd17 (diff)
downloadnextcloud-server-c60182065fa172d15867bff77bdc8a18ad0be709.tar.gz
nextcloud-server-c60182065fa172d15867bff77bdc8a18ad0be709.zip
Merge pull request #34773 from nextcloud/artonge/feat/dispatch_entry_removed_event_for_all_entries
Dispatch event for all removed entries
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/Cache.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 6440bf05a1d..9afeea7b573 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -575,7 +575,7 @@ class Cache implements ICache {
}
/**
- * Recursively remove all children of a folder
+ * Remove all children of a folder
*
* @param ICacheEntry $entry the cache entry of the folder to remove the children of
* @throws \OC\DatabaseException
@@ -583,6 +583,8 @@ class Cache implements ICache {
private function removeChildren(ICacheEntry $entry) {
$parentIds = [$entry->getId()];
$queue = [$entry->getId()];
+ $deletedIds = [];
+ $deletedPaths = [];
// we walk depth first through the file tree, removing all filecache_extended attributes while we walk
// and collecting all folder ids to later use to delete the filecache entries
@@ -591,6 +593,12 @@ class Cache implements ICache {
$childIds = array_map(function (ICacheEntry $cacheEntry) {
return $cacheEntry->getId();
}, $children);
+ $childPaths = array_map(function (ICacheEntry $cacheEntry) {
+ return $cacheEntry->getPath();
+ }, $children);
+
+ $deletedIds = array_merge($deletedIds, $childIds);
+ $deletedPaths = array_merge($deletedPaths, $childPaths);
$query = $this->getQueryBuilder();
$query->delete('filecache_extended')
@@ -619,6 +627,16 @@ class Cache implements ICache {
$query->setParameter('parentIds', $parentIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
$query->execute();
}
+
+ foreach (array_combine($deletedIds, $deletedPaths) as $fileId => $filePath) {
+ $cacheEntryRemovedEvent = new CacheEntryRemovedEvent(
+ $this->storage,
+ $filePath,
+ $fileId,
+ $this->getNumericStorageId()
+ );
+ $this->eventDispatcher->dispatchTyped($cacheEntryRemovedEvent);
+ }
}
/**