mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
add downloader
This commit is contained in:
1 parent
811dd73e13
commit
5380742513
11 files changed
+403
-94
No files matched your search
@@ -10,7 +10,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||
{
|
||||
let _timer = Timer::new("remove one".to_string());
|
||||
let mut writer = service.get_yomitan_writer()?;
|
||||
AppService::remove_yomitan_dictionary(&mut writer, "JMnedict")?;
|
||||
AppService::remove_yomitan_dictionary(&mut writer, "JMnedict.zip", "ja")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ pub enum CJDicError {
|
||||
|
||||
#[error("Not found")]
|
||||
NotFound,
|
||||
|
||||
#[error("Error: {0}")]
|
||||
Error(String),
|
||||
}
|
||||
|
||||
impl From<rusqlite::Error> for CJDicError {
|
||||
|
||||
@@ -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)?)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user