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)
| 391 | /// Use this for short-lived processes (agent hooks, background jobs) |
| 392 | /// where blocking on the init write lock would hang the process. |
| 393 | pub fn open_existing<P: AsRef<Path>>(path: P) -> Result<Self, RepositoryError> { |
| 394 | if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path.as_ref()) { |
| 395 | return Self::open_sandbox(working_root, canonical, &view); |
| 396 | } |
| 397 | let root = Self::find_root(path.as_ref())?; |
| 398 | let dot_dir = root.join(DOT_DIR); |
| 399 | |
| 400 | let pristine = Arc::new( |
| 401 | Pristine::open_existing(dot_dir.join("pristine.redb")) |
| 402 | .map_err(|e| RepositoryError::Database(e.to_string()))?, |
| 403 | ); |
| 404 | |
| 405 | let current_view = |
| 406 | Self::read_current_view(&dot_dir).unwrap_or_else(|_| DEFAULT_STACK.to_string()); |
| 407 | |
| 408 | let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY) |
| 409 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 410 | |
| 411 | let mut repository = Self { |
| 412 | root, |
| 413 | dot_dir, |
| 414 | current_view, |
| 415 | pristine, |
| 416 | change_store, |
| 417 | is_sandbox: false, |
| 418 | }; |
| 419 | repository.recover_pending_deferred_tree_alignment()?; |
| 420 | Ok(repository) |
| 421 | } |
| 422 | |
| 423 | /// Open an existing repository in read-only mode. |
| 424 | /// |
nothing calls this directly
no test coverage detected