check for yomitan init

This commit is contained in:
polv committed 2026-02-24 23:02:39 +07:00
1 parent dcfe074535
commit 3b5afbc34e
3 files changed
+16 -7

No files matched your search

+12 -3
View File
@@ -7,7 +7,7 @@ use std::{
},
};
use anyhow::Result;
use anyhow::{Ok, Result};
use rusqlite::Connection;
mod yomitan;
@@ -46,8 +46,17 @@ impl Database {
})
}
pub fn is_yomitan_dbfile_exists(&self) -> bool {
self.dir.join(YOMITAN_DBFILE).exists()
pub fn is_yomitan_dbfile_init(&self) -> Result<bool> {
let yomitan_db_path = self.dir.join(YOMITAN_DBFILE);
if yomitan_db_path.exists() {
return Ok(false);
}
let conn = Connection::open(yomitan_db_path)?;
let mut stmt = conn.prepare("SELECT 1 FROM dictionaries")?;
Ok(stmt.exists([])?)
}
pub fn yomitan(&self) -> Result<yomitan::YomitanDatabase> {
+2 -2
View File
@@ -20,8 +20,8 @@ impl AppService {
Ok(Self { db })
}
pub fn is_yomitan_setup_yet(&self) -> bool {
self.db.is_yomitan_dbfile_exists()
pub fn is_yomitan_setup_yet(&self) -> Result<bool, CJDicError> {
Ok(self.db.is_yomitan_dbfile_init()?)
}
pub fn search_yomitan(