You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Desktop: Make sure search engine can keep working when index is corrupted
This commit is contained in:
		| @@ -454,6 +454,11 @@ class SearchEngine { | ||||
| 			// when searching. | ||||
| 			// https://github.com/laurent22/joplin/issues/1075#issuecomment-459258856 | ||||
| 			query = query.replace(/-/g, ' '); | ||||
|  | ||||
| 			// 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 | ||||
| 			const sql = ` | ||||
| 				SELECT | ||||
| 					notes_fts.id, | ||||
| @@ -467,6 +472,7 @@ class SearchEngine { | ||||
| 				FROM notes_fts | ||||
| 				LEFT JOIN notes ON notes_fts.id = notes.id | ||||
| 				WHERE notes_fts MATCH ? | ||||
| 				AND notes.user_updated_time IS NOT NULL | ||||
| 			`; | ||||
| 			try { | ||||
| 				const rows = await this.db().selectAll(sql, [query]); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user