Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ public List<NoteInfo> removeFolder(String folderPath, AuthenticationInfo subject
Folder folder = getFolder(folderPath);
List<NoteInfo> noteInfos = folder.getParent().removeFolder(folder.getName(), subject);

// update notesInfo
// update notesInfo and evict the deleted notes from the cache, mirroring removeNote
for (NoteInfo noteInfo : noteInfos) {
this.notesInfo.remove(noteInfo.getId());
this.noteCache.removeNote(noteInfo.getId());
}

return noteInfos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ void testLruCache() throws IOException {
assertTrue(noteManager.containsNote(noteNew3.getPath()));
}

@Test
void testRemoveFolderEvictsNoteCache() throws IOException {
// add 2 notes under the same folder
Note note1 = createNote("/folder1/note1");
Note note2 = createNote("/folder1/note2");
noteManager.addNote(note1, AuthenticationInfo.ANONYMOUS);
noteManager.addNote(note2, AuthenticationInfo.ANONYMOUS);
assertEquals(2, noteManager.getCacheSize());

// remove folder should evict its notes from the cache as well
noteManager.removeFolder("/folder1", AuthenticationInfo.ANONYMOUS);
assertEquals(0, noteManager.getCacheSize());
}

@Test
void testConcurrentOperation() throws Exception {
int threshold = 10, noteNum = 150;
Expand Down
Loading