[ZEPPELIN-6345] Fire NoteRemove event for each note when deleting a folder#5292
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.
|
LGTM :) |
ParkGyeongTae
left a comment
There was a problem hiding this comment.
LGTM. The root cause analysis is accurate — moving noteManager.removeFolder()
to after the per-note cleanup ensures processNote() can still find each note
in notesInfo and fire NoteRemoveEvent correctly.
While reviewing this, I noticed that removeFolder does not evict note cache
entries via noteCache.removeNote(), which is a pre-existing issue unrelated
to this fix. I've filed a separate Jira ticket for it — feel free to take a
look if you're interested.
https://issues.apache.org/jira/projects/ZEPPELIN/issues/ZEPPELIN-6529
|
@ParkGyeongTae Thanks for filing ZEPPELIN-6529 and letting me know! Confirmed the bug and sent a PR here: #5296 |
|
Thanks for the quick follow-up! I'll take a look at #5296. |
|
Merged into master (0c4b30f). |
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: