Skip to content

Commit 2830eea

Browse files
committed
Dispatch event for all remove entry
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 3ff5683 commit 2830eea

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/private/Files/Cache/Cache.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,14 +573,16 @@ private function getSubFolders(ICacheEntry $entry) {
573573
}
574574

575575
/**
576-
* Recursively remove all children of a folder
576+
* Remove all children of a folder
577577
*
578578
* @param ICacheEntry $entry the cache entry of the folder to remove the children of
579579
* @throws \OC\DatabaseException
580580
*/
581581
private function removeChildren(ICacheEntry $entry) {
582582
$parentIds = [$entry->getId()];
583583
$queue = [$entry->getId()];
584+
$deletedIds = [];
585+
$deletedPaths = [];
584586

585587
// we walk depth first through the file tree, removing all filecache_extended attributes while we walk
586588
// and collecting all folder ids to later use to delete the filecache entries
@@ -589,6 +591,12 @@ private function removeChildren(ICacheEntry $entry) {
589591
$childIds = array_map(function (ICacheEntry $cacheEntry) {
590592
return $cacheEntry->getId();
591593
}, $children);
594+
$childPaths = array_map(function (ICacheEntry $cacheEntry) {
595+
return $cacheEntry->getPath();
596+
}, $children);
597+
598+
$deletedIds = array_merge($deletedIds, $childIds);
599+
$deletedPaths = array_merge($deletedPaths, $childPaths);
592600

593601
$query = $this->getQueryBuilder();
594602
$query->delete('filecache_extended')
@@ -617,6 +625,16 @@ private function removeChildren(ICacheEntry $entry) {
617625
$query->setParameter('parentIds', $parentIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
618626
$query->execute();
619627
}
628+
629+
foreach (array_combine($deletedIds, $deletedPaths) as $fileId => $filePath) {
630+
$cacheEntryRemovedEvent = new CacheEntryRemovedEvent(
631+
$this->storage,
632+
$filePath,
633+
$fileId,
634+
$this->getNumericStorageId()
635+
);
636+
$this->eventDispatcher->dispatchTyped($cacheEntryRemovedEvent);
637+
}
620638
}
621639

622640
/**

0 commit comments

Comments
 (0)