MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / open_existing

Method open_existing

atomic-repository/src/repository/mod.rs:342–367  ·  view source on GitHub ↗

Open an existing repository without the table-init write lock. Like [`open`](Self::open) but uses [`Pristine::open_existing`] which skips the `begin_write()` table-initialization transaction. The returned repository still supports write operations — the write lock is deferred until `write_txn()` is actually called. Use this for short-lived processes (agent hooks, background jobs) where blocking

(path: P)

Source from the content-addressed store, hash-verified

340 /// Use this for short-lived processes (agent hooks, background jobs)
341 /// where blocking on the init write lock would hang the process.
342 pub fn open_existing<P: AsRef<Path>>(path: P) -> Result<Self, RepositoryError> {
343 if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path.as_ref()) {
344 return Self::open_sandbox(working_root, canonical, &view);
345 }
346 let root = Self::find_root(path.as_ref())?;
347 let dot_dir = root.join(DOT_DIR);
348
349 let pristine = Arc::new(
350 Pristine::open_existing(dot_dir.join("pristine.redb"))
351 .map_err(|e| RepositoryError::Database(e.to_string()))?,
352 );
353
354 let current_view =
355 Self::read_current_view(&dot_dir).unwrap_or_else(|_| DEFAULT_STACK.to_string());
356
357 let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY)
358 .map_err(|e| RepositoryError::Database(e.to_string()))?;
359
360 Ok(Self {
361 root,
362 dot_dir,
363 current_view,
364 pristine,
365 change_store,
366 })
367 }
368
369 /// Open an existing repository in read-only mode.
370 ///

Callers

nothing calls this directly

Calls 2

detect_sandboxFunction · 0.85
as_refMethod · 0.80

Tested by

no test coverage detected