This commit is contained in:
thePR0M3TH3AN
2025-05-21 20:14:56 -04:00
parent 2a388e980f
commit 99f72af4bc

View File

@@ -52,16 +52,15 @@ fn main() -> Result<()> {
/* ── open DB (runs migrations) ───────────────────────────── */ /* ── open DB (runs migrations) ───────────────────────────── */
let mut conn = db::open(&cfg.db_path)?; let mut conn = db::open(&cfg.db_path)?;
/* ── command dispatch ────────────────────────────────────── */ /* ── command dispatch ────────────────────────────────────── */
match args.command { match args.command {
Commands::Completions { .. } => {} // handled above Commands::Completions { .. } => {} // handled above
/* ---- init ------------------------------------------------ */ /* ---- init ------------------------------------------------ */
Commands::Init => { Commands::Init => {
info!("Database initialised at {}", cfg.db_path.display()); info!("Database initialised at {}", cfg.db_path.display());
let cwd = env::current_dir().context("getting current directory")?; let cwd = env::current_dir().context("getting current directory")?;
let count = let count = scan::scan_directory(&mut conn, &cwd).context("initial scan failed")?;
scan::scan_directory(&mut conn, &cwd).context("initial scan failed")?;
info!("Initial scan complete indexed/updated {count} files"); info!("Initial scan complete indexed/updated {count} files");
} }
@@ -76,11 +75,8 @@ match args.command {
if dirty { if dirty {
let dirty_ids = take_dirty(&conn)?; let dirty_ids = take_dirty(&conn)?;
for id in dirty_ids { for id in dirty_ids {
let path: String = conn.query_row( let path: String =
"SELECT path FROM files WHERE id = ?1", conn.query_row("SELECT path FROM files WHERE id = ?1", [id], |r| r.get(0))?;
[id],
|r| r.get(0),
)?;
scan::scan_directory(&mut conn, Path::new(&path))?; scan::scan_directory(&mut conn, Path::new(&path))?;
} }
} else { } else {
@@ -152,9 +148,10 @@ match args.command {
Commands::Version(v_cmd) => cli::version::run(&v_cmd, &mut conn, args.format)?, Commands::Version(v_cmd) => cli::version::run(&v_cmd, &mut conn, args.format)?,
Commands::Event(e_cmd) => cli::event::run(&e_cmd, &mut conn, args.format)?, Commands::Event(e_cmd) => cli::event::run(&e_cmd, &mut conn, args.format)?,
Commands::Watch(watch_cmd) => cli::watch::run(&watch_cmd, &mut conn, args.format)?, Commands::Watch(watch_cmd) => cli::watch::run(&watch_cmd, &mut conn, args.format)?,
} }
Ok(()) Ok(())
}
/* ─────────────────── helpers & sub-routines ─────────────────── */ /* ─────────────────── helpers & sub-routines ─────────────────── */