diff --git a/src/updater.rs b/src/updater.rs index d8257e7..96cdff1 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -40,7 +40,7 @@ pub async fn init_db( update_url: &str, ) -> Result<(), Box> { let reader = if db_path.exists() { - load_db(db_path)? + validate_db_off_runtime(db_path).await? } else { if let Some(parent) = db_path.parent() { fs::create_dir_all(parent).await?; @@ -66,7 +66,7 @@ async fn download_db( return Err(e); } - let reader = match validate_db(&tmp_path) { + let reader = match validate_db_off_runtime(&tmp_path).await { Ok(r) => r, Err(e) => { let _ = fs::remove_file(&tmp_path).await; @@ -105,6 +105,16 @@ fn validate_db(path: &Path) -> Result Result> { + let path = path.to_owned(); + tokio::task::spawn_blocking(move || validate_db(&path)).await? +} + pub fn spawn_updater( shared_db: SharedDb, db_path: PathBuf,