summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2022-10-24 16:17:27 +0200
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>2023-01-31 13:30:10 +0000
commit2830eeac7ea261e38cc8e03847c44a352733cd17 (patch)
treed9a3a7aac9884f7b989b3cc3dd4683d7a4d61edf /lib
parent3ff568342b6c70dc90daa658e69f93049787e77c (diff)
downloadnextcloud-server-2830eeac7ea261e38cc8e03847c44a352733cd17.tar.gz
nextcloud-server-2830eeac7ea261e38cc8e03847c44a352733cd17.zip
Dispatch event for all remove entry
Signed-off-by: Louis Chemineau <louis@chmn.me>
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 ec284282178..d389d0df20a 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -573,7 +573,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
@@ -581,6 +581,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
@@ -589,6 +591,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')
@@ -617,6 +625,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);
+ }
}
/**