mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 11:31:01 +00:00
Make the search index creation during migration respect SEARCH_INDEX (#689)
* Make the search index creation during migration respect SEARCH_INDEX * Make the search subcommand respect it too
This commit is contained in:
parent
c0469c69c1
commit
f0846ff546
3 changed files with 17 additions and 11 deletions
|
@ -1,10 +1,10 @@
|
||||||
-- Your SQL goes here
|
-- Your SQL goes here
|
||||||
--#!|conn: &Connection, path: &Path| {
|
--#!|conn: &Connection, path: &Path| {
|
||||||
--#! let mut pb = path.to_path_buf();
|
--#! use std::env::var;
|
||||||
--#! pb.push("search_index");
|
--#! let mut pb = Path::new(&var("SEARCH_INDEX")
|
||||||
|
--#! .unwrap_or_else(|_|"search_index".to_owned())).to_path_buf();
|
||||||
--#! let searcher = super::search::Searcher::create(&pb)?;
|
--#! let searcher = super::search::Searcher::create(&pb)?;
|
||||||
--#! searcher.fill(conn)?;
|
--#! searcher.fill(conn)?;
|
||||||
--#! searcher.commit();
|
--#! searcher.commit();
|
||||||
--#! Ok(())
|
--#! Ok(())
|
||||||
--#!}
|
--#!}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
-- Your SQL goes here
|
-- Your SQL goes here
|
||||||
--#!|conn: &Connection, path: &Path| {
|
--#!|conn: &Connection, path: &Path| {
|
||||||
--#! let mut pb = path.to_path_buf();
|
--#! use std::env::var;
|
||||||
--#! pb.push("search_index");
|
--#! let mut pb = Path::new(&var("SEARCH_INDEX")
|
||||||
|
--#! .unwrap_or_else(|_|"search_index".to_owned())).to_path_buf();
|
||||||
--#! let searcher = super::search::Searcher::create(&pb)?;
|
--#! let searcher = super::search::Searcher::create(&pb)?;
|
||||||
--#! searcher.fill(conn)?;
|
--#! searcher.fill(conn)?;
|
||||||
--#! searcher.commit();
|
--#! searcher.commit();
|
||||||
--#! Ok(())
|
--#! Ok(())
|
||||||
--#!}
|
--#!}
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,11 @@ fn init<'a>(args: &ArgMatches<'a>, conn: &Connection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searcher>) {
|
fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searcher>) {
|
||||||
let path = args.value_of("path").unwrap_or(".");
|
let path = args.value_of("path");
|
||||||
let path = Path::new(path).join("search_index");
|
let path = match path {
|
||||||
|
Some(path) => Path::new(path).join("search_index"),
|
||||||
|
None => Path::new(&CONFIG.search_index).to_path_buf(),
|
||||||
|
};
|
||||||
let searcher = searcher.unwrap_or_else(|| Searcher::open(&path).unwrap());
|
let searcher = searcher.unwrap_or_else(|| Searcher::open(&path).unwrap());
|
||||||
|
|
||||||
searcher.fill(conn).expect("Couldn't import post");
|
searcher.fill(conn).expect("Couldn't import post");
|
||||||
|
@ -103,9 +106,12 @@ fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searche
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlock<'a>(args: &ArgMatches<'a>) {
|
fn unlock<'a>(args: &ArgMatches<'a>) {
|
||||||
let path = args.value_of("path").unwrap_or(".");
|
let path = match args.value_of("path") {
|
||||||
let meta = Path::new(path).join("search_index/.tantivy-meta.lock");
|
None => Path::new(&CONFIG.search_index),
|
||||||
|
Some(x) => Path::new(x),
|
||||||
|
};
|
||||||
|
let meta = Path::new(path).join(".tantivy-meta.lock");
|
||||||
remove_file(meta).unwrap();
|
remove_file(meta).unwrap();
|
||||||
let writer = Path::new(path).join("search_index/.tantivy-writer.lock");
|
let writer = Path::new(path).join(".tantivy-writer.lock");
|
||||||
remove_file(writer).unwrap();
|
remove_file(writer).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue