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)
| 354 | /// Use this for short-lived processes (agent hooks, background jobs) |
| 355 | /// where blocking on the init write lock would hang the process. |
| 356 | pub fn open_existing<P: AsRef<Path>>(path: P) -> Result<Self, RepositoryError> { |
| 357 | if let Some((working_root, canonical, view)) = sandbox::detect_sandbox(path.as_ref()) { |
| 358 | return Self::open_sandbox(working_root, canonical, &view); |
| 359 | } |
| 360 | let root = Self::find_root(path.as_ref())?; |
| 361 | let dot_dir = root.join(DOT_DIR); |
| 362 | |
| 363 | let pristine = Arc::new( |
| 364 | Pristine::open_existing(dot_dir.join("pristine.redb")) |
| 365 | .map_err(|e| RepositoryError::Database(e.to_string()))?, |
| 366 | ); |
| 367 | |
| 368 | let current_view = |
| 369 | Self::read_current_view(&dot_dir).unwrap_or_else(|_| DEFAULT_STACK.to_string()); |
| 370 | |
| 371 | let change_store = ChangeStore::new(dot_dir.join("changes"), DEFAULT_CACHE_CAPACITY) |
| 372 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 373 | |
| 374 | let mut repository = Self { |
| 375 | root, |
| 376 | dot_dir, |
| 377 | current_view, |
| 378 | pristine, |
| 379 | change_store, |
| 380 | is_sandbox: false, |
| 381 | }; |
| 382 | repository.recover_pending_deferred_tree_alignment()?; |
| 383 | Ok(repository) |
| 384 | } |
| 385 | |
| 386 | /// Open an existing repository in read-only mode. |
| 387 | /// |
nothing calls this directly
no test coverage detected