Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch event for all removed entries #34773

Merged

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Oct 24, 2022

When removing a folder, dispatch the event for all the deleted entries and not only for the folder.

Does it make sense, or was the old behavior on purpose ?

@artonge artonge added the 3. to review Waiting for reviews label Oct 24, 2022
@artonge artonge added this to the Nextcloud 26 milestone Oct 24, 2022
@artonge artonge self-assigned this Oct 24, 2022
@artonge artonge marked this pull request as ready for review October 24, 2022 14:21
@artonge artonge requested review from icewind1991, a team, juliushaertl and skjnldsv and removed request for a team October 24, 2022 14:21
@artonge artonge changed the title Dispatch event for all remove entry Dispatch event for all removed entries Oct 24, 2022
@juliushaertl
Copy link
Member

Sounds like something we should have, I'd just be cautious about possible performance impact on large folder deletion. Did you attempt to fix a specific case with this?

@artonge
Copy link
Contributor Author

artonge commented Oct 25, 2022

Sounds like something we should have, I'd just be cautious about possible performance impact on large folder deletion. Did you attempt to fix a specific case with this?

Performance wise, I think that the change simply move the iteration work from the listener to the dispatcher. Meaning, when a folder is deleted, instead of having to look for children in every listener, we do it once on the dispatcher side.

So we are comparing the load of emitting more events to the load of listing directories multiple times.

I think it also makes more sense regarding the naming of the event. If you listen to CacheEntryRemovedEvent you expect to receive the event for every entry, no ? So without this change, you miss on a lot of entry deletion.

I two specific cases:

  1. In photos, where we delete file entries from albums when they are deleted:
    https://github.com/nextcloud/photos/blob/f034ce6517b0c523dacce17d976da0945c5cdb7e/lib/Listener/CacheEntryRemovedListener.php
  2. And this PR in server that improves how we manage metadata with events:
    Listen to cache event for managing metadata #34586

@artonge
Copy link
Contributor Author

artonge commented Nov 2, 2022

Ping for review :)

@PVince81
Copy link
Member

PVince81 commented Nov 2, 2022

I'd like to know what @icewind1991 thinks

I vaguely remember that some events are purposefully only triggered on the container and not on all children, for performance reasons

@juliushaertl
Copy link
Member

🏓 @icewind1991 for some input

@artonge
Copy link
Contributor Author

artonge commented Jan 31, 2023

/rebase

Signed-off-by: Louis Chemineau <louis@chmn.me>
@nextcloud-command nextcloud-command force-pushed the artonge/feat/dispatch_entry_removed_event_for_all_entries branch from 91e6c73 to 2830eea Compare January 31, 2023 13:30
@blizzz blizzz mentioned this pull request Feb 1, 2023
@icewind1991
Copy link
Member

Not the best in case of performance but probably better than the alternatives that can be done easily

@artonge artonge requested a review from a team February 2, 2023 14:33
@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
@blizzz blizzz mentioned this pull request Mar 7, 2023
@blizzz blizzz modified the milestones: Nextcloud 26, Nextcloud 27 Mar 9, 2023
@come-nc come-nc merged commit c601820 into master Mar 21, 2023
@come-nc come-nc deleted the artonge/feat/dispatch_entry_removed_event_for_all_entries branch March 21, 2023 10:42
@marcelklehr
Copy link
Member

This is kinda a breaking change. Should be added here: #37039

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants