diff --git a/crates/xmedia-bot/src/db.rs b/crates/xmedia-bot/src/db.rs index da7826f..a4e3bd5 100644 --- a/crates/xmedia-bot/src/db.rs +++ b/crates/xmedia-bot/src/db.rs @@ -135,13 +135,10 @@ pub fn open_db(path: &str) -> rusqlite::Result { /// Opens the shared DB file, runs the merged schema for all three tables and /// returns a pool for it. One call per process in production (the stores -/// share the returned pool); tests call it per tempdir. +/// share the returned pool); tests call it per tempdir. The file's directory +/// must exist already — [`crate::handlers::db_path`] is what creates it, and +/// it is the only caller that takes a path it did not get from a tempdir. pub fn open_store(path: &str) -> rusqlite::Result> { - if let Some(parent) = std::path::Path::new(path).parent() - && !parent.as_os_str().is_empty() - { - std::fs::create_dir_all(parent).map_err(rusqlite_error)?; - } let conn = open_db(path)?; schema_init(&conn)?; migrate(&conn)?; @@ -182,10 +179,6 @@ fn migrate(conn: &Connection) -> rusqlite::Result<()> { Ok(()) } -fn rusqlite_error(e: std::io::Error) -> rusqlite::Error { - rusqlite::Error::ToSqlConversionFailure(Box::new(e)) -} - /// Creates the `tasks`, `chat_state` and `link_cache` tables (idempotent). /// The three stores used to own their own schema; keeping it in one place /// means one initialization for the whole database file.