From 28066d49d14516008e2ba1e9cf3dbd01a95aa788 Mon Sep 17 00:00:00 2001 From: jakka Date: Wed, 2 Jul 2025 17:34:49 +0300 Subject: removed all async code --- src/main.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 206a13b..da62d1e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,8 @@ use std::{ }, }; +use crate::db::Database; + fn build_cli() -> Command { command!() .arg( @@ -90,16 +92,13 @@ fn main() -> Result<()> { r.store(false, Ordering::SeqCst); })?; - let conn = if let Some(path) = args.get_one::("db") { - smol::block_on(async { db::Database::new(path).await })? - } else { - smol::block_on(async { db::open_default_db().await })? - }; + let dbpool = db::open_db(args.get_one::("db"))?; let path = args.get_one::("path"); if path.is_none() && !args.get_flag("clean") && !args.get_flag("doit") { - let count = smol::block_on(async { conn.get_toencode_number().await })?; + let conn = Database::new(dbpool.get()?); + let count = conn.get_toencode_number()?; println!("Files to reencode:\t{}", style(count).green()); return Ok(()); } @@ -110,17 +109,17 @@ fn main() -> Result<()> { if let Some(realpath) = path { let hanlder = running.clone(); - pool.install(|| files::index_files_recursively(realpath, &conn, hanlder))?; + pool.install(|| files::index_files_recursively(realpath, &dbpool, hanlder))?; } if args.get_flag("clean") { let handler = running.clone(); - pool.install(|| files::clean_files(&conn, handler))?; + pool.install(|| files::clean_files(&dbpool, handler))?; } if args.get_flag("doit") { let hanlder = running.clone(); - pool.install(|| files::reencode_files(&conn, hanlder))?; + pool.install(|| files::reencode_files(&dbpool, hanlder))?; } Ok::<(), anyhow::Error>(()) } -- cgit v1.3.1