Refactor and simplify code in index.rs, scan.rs, and database.rs

- Removed unnecessary references and improved clarity in `Indexer` method calls.
- Reorganized conditionals and eliminated redundant variable assignments in `scan.rs`.
- Simplified database initialization handling by removing unused commented-out code and improving formatting in `database.rs`.
This commit is contained in:
elipeter 2025-06-23 17:49:15 +02:00
parent 8bc16ac940
commit 952e83453a
3 changed files with 9 additions and 18 deletions

View file

@ -59,12 +59,12 @@ pub mod index {
let flags = OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_FULL_MUTEX;
let manager = SqliteConnectionManager::file(&database_path).with_flags(flags);
let manager = SqliteConnectionManager::file(database_path).with_flags(flags);
let pool = Arc::new(Pool::new(manager)?);
{
let conn = pool.get()?;
conn.pragma_update(None, "journal_mode", &"WAL")?;
conn.pragma_update(None, "journal_mode", "WAL")?;
conn.execute_batch(SCHEMA)?;
}
Ok(pool)
@ -81,14 +81,6 @@ pub mod index {
// helper so code below can treat PooledConnection like &Connection
fn c(&self) -> &Connection { self.conn.deref() }
/// Open (or create) the DB at `database_path` for the given project name.
// pub fn new(project: &str, database_path: &Path) -> Result<Self, Box<dyn std::error::Error>> {
// let conn = Connection::open(database_path)?;
// conn.pragma_update(None, "journal_mode", &"WAL")?;
// conn.execute_batch(SCHEMA)?;
// Ok(Self { conn, project: project.to_owned() })
// }
/// Return true when the file *content* or *mtime* changed since the last scan.
pub fn should_scan(&self, path: &Path) -> Result<bool, Box<dyn std::error::Error>> {
let meta = fs::metadata(path)?;