Skip to content

Commit

Permalink
All: Fixed search when the index contains non-existing notes
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Jun 24, 2021
1 parent 65d8722 commit 5ecac21
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions packages/lib/services/searchengine/SearchEngineUtils.ts
Expand Up @@ -70,16 +70,10 @@ export default class SearchEngineUtils {
if (isTodoAutoAdded) delete sortedNotes[idx].is_todo;
}

// Note that when the search engine index is somehow corrupted, it might contain
// references to notes that don't exist. Not clear how it can happen, but anyway
// handle it here by checking if `user_updated_time` IS NOT NULL. Was causing this
// issue: https://discourse.joplinapp.org/t/how-to-recover-corrupted-database/9367
if (noteIds.length !== notes.length) {
// remove null objects
return sortedNotes.filter(n => n);
} else {
return sortedNotes;
}

// Note that when the search engine index is somehow corrupted, it might
// contain references to notes that don't exist. Not clear how it can
// happen, but anyway handle it here. Was causing this issue:
// https://discourse.joplinapp.org/t/how-to-recover-corrupted-database/9367
return sortedNotes.filter(n => n);
}
}

0 comments on commit 5ecac21

Please sign in to comment.