Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc41340b

Browse files
authored
Dont crash the dashboard if search index is not built (#1018)
1 parentb04bede commitc41340b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎pgml-dashboard/src/utils/markdown.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,24 @@ impl SearchIndex {
11931193
}
11941194

11951195
pubfnopen() -> tantivy::Result<SearchIndex>{
1196-
let index = tantivy::Index::open_in_dir(&Self::path())?;
1196+
let path =Self::path();
1197+
1198+
if !path.exists(){
1199+
std::fs::create_dir(&path)
1200+
.expect("failed to create search_index directory, is the filesystem writable?");
1201+
}
1202+
1203+
let index =match tantivy::Index::open_in_dir(&path){
1204+
Ok(index) => index,
1205+
Err(err) =>{
1206+
warn!(
1207+
"Failed to open Tantivy index in '{}', creating an empty one, error: {}",
1208+
path.display(),
1209+
err
1210+
);
1211+
Index::create_in_dir(&path,Self::schema())?
1212+
}
1213+
};
11971214

11981215
let reader = index.reader_builder().try_into()?;
11991216

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp