add downloader

This commit is contained in:
polv committed 2026-03-04 02:09:41 +07:00
1 parent 811dd73e13
commit 5380742513
11 files changed
+403 -94

No files matched your search

+6 -4
View File
@@ -339,7 +339,7 @@ impl YomitanWriter {
if let Some(row) = rows.next()? {
let is_outdated: bool = row.get(0)?;
if is_outdated {
self.drop_dictionary(title)?;
self.drop_dictionary(bundle_name, lang)?;
} else {
return Ok(YomitanZipImportResult {
exists: true,
@@ -608,9 +608,11 @@ impl YomitanWriter {
})
}
pub fn drop_dictionary(&self, title: &str) -> Result<()> {
self.conn
.execute("DELETE FROM dictionaries WHERE title = ?1", [title])?;
pub fn drop_dictionary(&self, bundle_name: &str, lang: &str) -> Result<()> {
self.conn.execute(
"DELETE FROM dictionaries WHERE bundle_name = ?1 AND lang = ?2",
[bundle_name, lang],
)?;
Ok(())
}
+3
View File
@@ -25,6 +25,9 @@ pub enum CJDicError {
#[error("Not found")]
NotFound,
#[error("Error: {0}")]
Error(String),
}
impl From<rusqlite::Error> for CJDicError {
+3 -2
View File
@@ -228,8 +228,9 @@ impl AppService {
pub fn remove_yomitan_dictionary(
writer: &mut YomitanWriter,
title: &str,
bundle_name: &str,
lang: &str,
) -> Result<(), CJDicError> {
Ok(writer.drop_dictionary(title)?)
Ok(writer.drop_dictionary(bundle_name, lang)?)
}
}