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