Don't care about needless return value of closures

This commit is contained in:
Kitaiti Makoto 2020-07-19 08:24:17 +09:00
parent 5cca66b346
commit 5e30bede40

View File

@ -104,26 +104,23 @@ Then try to restart Plume.
let mut open_searcher = let mut open_searcher =
UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers); UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers);
if let Err(Error::Search(SearcherError::InvalidIndexDataError)) = open_searcher { if let Err(Error::Search(SearcherError::InvalidIndexDataError)) = open_searcher {
UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers) if UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers).is_err() {
.or_else(|_| {
let current_path = Path::new(&CONFIG.search_index); let current_path = Path::new(&CONFIG.search_index);
let backup_path = format!("{}.{}", &current_path.display(), Utc::now().timestamp()); let backup_path = format!("{}.{}", &current_path.display(), Utc::now().timestamp());
let backup_path = Path::new(&backup_path); let backup_path = Path::new(&backup_path);
fs::rename(current_path, backup_path) fs::rename(current_path, backup_path)
.expect("main: error on backing up search index directory for recreating"); .expect("main: error on backing up search index directory for recreating");
UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers).and_then( if UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers).is_ok() {
|searcher| {
if fs::remove_dir_all(backup_path).is_err() { if fs::remove_dir_all(backup_path).is_err() {
eprintln!( eprintln!(
"error on removing backup directory: {}. it remains", "error on removing backup directory: {}. it remains",
backup_path.display() backup_path.display()
); );
} }
Ok(searcher) } else {
}, panic!("main: error on recreating search index in new index format. remove search index and run `plm search init` manually");
) }
}) }
.expect("main: error on recreating search index in new index format. remove search index and run `plm search init` manually");
open_searcher = UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers); open_searcher = UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers);
} }
#[allow(clippy::match_wild_err_arm)] #[allow(clippy::match_wild_err_arm)]