Skip to content

[ZEPPELIN-6345] Fire NoteRemove event for each note when deleting a folder#5292

Open
HwangRock wants to merge 1 commit into
apache:masterfrom
HwangRock:ZEPPELIN-6345-pr
Open

[ZEPPELIN-6345] Fire NoteRemove event for each note when deleting a folder#5292
HwangRock wants to merge 1 commit into
apache:masterfrom
HwangRock:ZEPPELIN-6345-pr

Conversation

@HwangRock

@HwangRock HwangRock commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What is this PR for?

Deleting a folder left its notes searchable after removal. removeFolder(String, AuthenticationInfo) in Notebook called noteManager.removeFolder first, which detached the notes from the tree, so the following removeNote(noteId) loaded a null note and skipped fireNoteRemoveEvent. SearchService.deleteNoteIndex was 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 as removeNote(Note, AuthenticationInfo) (setRemoved, removeNoteAuth, fireNoteRemoveEvent) for each note, and only then deletes the folder. This also removes the pre-existing NotebookRepo.remove is called twice TODO, 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?

  • Added NotebookTest#testRemoveFolderFiresNoteRemoveEventForEachNote: creates two notes under /folder1, registers a NoteEventListener counting onNoteRemove, calls removeFolder("/folder1", ...), and asserts the event fired once per note. Fails before the change (count 0), passes after.
  • Manual: create notes, move them to trash, empty the trash, then search for a deleted note. Before the fix it still appears in results; after the fix it is gone.

Questions:

  • Does the license files need to update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

…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.
@hyunw9

hyunw9 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

LGTM :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants