[ZEPPELIN-6345] Fire NoteRemove event for each note when deleting a folder#5292
Open
HwangRock wants to merge 1 commit into
Open
[ZEPPELIN-6345] Fire NoteRemove event for each note when deleting a folder#5292HwangRock wants to merge 1 commit into
HwangRock wants to merge 1 commit into
Conversation
…older Deleting a folder (emptying trash or removing a folder permanently) left the notes searchable because their remove listeners never fired, so the Lucene search index kept stale documents for the deleted notes. removeFolder(String, AuthenticationInfo) called noteManager.removeFolder first, which detached the notes from the tree, so the following removeNote(noteId) loaded a null note and skipped fireNoteRemoveEvent. deleteNoteIndex was never invoked and the notes stayed in the search index after deletion. Load the notes non-destructively via NoteManager.getNoteInfoRecursively, fire the per-note remove cleanup (setRemoved, removeNoteAuth, fireNoteRemoveEvent) mirroring removeNote(Note, AuthenticationInfo), then delete the folder. This also removes the pre-existing "NotebookRepo.remove is called twice" TODO.
Contributor
|
LGTM :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
Deleting a folder left its notes searchable after removal.
removeFolder(String, AuthenticationInfo)inNotebookcallednoteManager.removeFolderfirst, which detached the notes from the tree, so the followingremoveNote(noteId)loaded anullnote and skippedfireNoteRemoveEvent.SearchService.deleteNoteIndexwas therefore never invoked and the Lucene search index kept stale documents for the deleted notes, so they still showed up in search results after emptying the trash or removing a folder.This PR loads the notes non-destructively via a new
NoteManager.getNoteInfoRecursively, runs the same per-note cleanup asremoveNote(Note, AuthenticationInfo)(setRemoved,removeNoteAuth,fireNoteRemoveEvent) for each note, and only then deletes the folder. This also removes the pre-existingNotebookRepo.remove is called twiceTODO, since the repo remove now happens once.What type of PR is it?
Bug Fix
What is the Jira issue?
Screenshots (if appropriate)
2026-07-12.5.44.20.mov
How should this be tested?
NotebookTest#testRemoveFolderFiresNoteRemoveEventForEachNote: creates two notes under/folder1, registers aNoteEventListenercountingonNoteRemove, callsremoveFolder("/folder1", ...), and asserts the event fired once per note. Fails before the change (count0), passes after.Questions: