From 50753b3a6590be65c62e0407e328ac33b655e709 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 18 Jul 2020 09:40:58 +0900 Subject: [PATCH] Recreate search index if its format is outdated --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e52fde7b..9478e807 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,8 +98,15 @@ Then try to restart Plume. } let workpool = ScheduledThreadPool::with_name("worker {}", num_cpus::get()); // we want a fast exit here, so + let mut open_searcher = + UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers); + if let Err(Error::Search(SearcherError::InvalidIndexDataError)) = open_searcher { + UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers) + .expect("main: recreating search index error. Try backing up search index, removing it and running `plm search init`"); + open_searcher = UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers); + } #[allow(clippy::match_wild_err_arm)] - let searcher = match UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers) { + let searcher = match open_searcher { Err(Error::Search(e)) => match e { SearcherError::WriteLockAcquisitionError => panic!( r#"