Open or create the snapshot database at `{data_dir}/array_sync/snapshots.redb`.
(data_dir: &Path)
| 70 | impl OriginSnapshotStore { |
| 71 | /// Open or create the snapshot database at `{data_dir}/array_sync/snapshots.redb`. |
| 72 | pub fn open(data_dir: &Path) -> crate::Result<Arc<Self>> { |
| 73 | let dir = data_dir.join("array_sync"); |
| 74 | std::fs::create_dir_all(&dir).map_err(|e| crate::Error::Storage { |
| 75 | engine: "array_sync".into(), |
| 76 | detail: format!("create dir {}: {e}", dir.display()), |
| 77 | })?; |
| 78 | let path = dir.join("snapshots.redb"); |
| 79 | let db = Database::create(&path).map_err(|e| crate::Error::Storage { |
| 80 | engine: "array_sync".into(), |
| 81 | detail: format!("open snapshots db {}: {e}", path.display()), |
| 82 | })?; |
| 83 | Self::init(db) |
| 84 | } |
| 85 | |
| 86 | /// In-memory-only store for tests. |
| 87 | pub fn open_in_memory() -> crate::Result<Arc<Self>> { |