MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / open

Method open

src/db/connection.rs:156–176  ·  view source on GitHub ↗

Opens an existing database at `db_path`, applies performance pragmas, and runs any pending schema migrations. Returns `(Self, migrated)` where `migrated` is `true` if schema migrations were applied during open.

(db_path: &Path)

Source from the content-addressed store, hash-verified

154 /// Returns `(Self, migrated)` where `migrated` is `true` if schema
155 /// migrations were applied during open.
156 pub async fn open(db_path: &Path) -> Result<(Self, bool)> {
157 let db =
158 Builder::new_local(db_path)
159 .build()
160 .await
161 .map_err(|e| TraceDecayError::Database {
162 message: format!("failed to open database: {e}"),
163 operation: "open".to_string(),
164 })?;
165
166 let conn = db.connect().map_err(|e| TraceDecayError::Database {
167 message: format!("failed to connect to database: {e}"),
168 operation: "open".to_string(),
169 })?;
170
171 let file_size = std::fs::metadata(db_path).map_or(0, |m| m.len());
172 Self::apply_pragmas(&conn, file_size).await?;
173 let migrated = migrations::migrate(&conn).await?;
174
175 Ok((Self { conn, _db: db }, migrated))
176 }
177
178 /// Opens an existing database in read-only mode.
179 ///

Callers 13

write_private_fileFunction · 0.45
read_payload_fileFunction · 0.45
create_lock_fileFunction · 0.45
append_run_recordFunction · 0.45
set_mtimeFunction · 0.45
install_steering_rulesFunction · 0.45
install_mcp_serverFunction · 0.45
install_claude_md_rulesFunction · 0.45

Calls 3

migrateFunction · 0.85
buildMethod · 0.80
connectMethod · 0.45

Tested by 2

set_mtimeFunction · 0.36