op_heads_store: convert load() to take &Path like other factories

This commit is contained in:
Daniel Ploch 2022-12-15 18:53:43 -05:00 committed by Daniel Ploch
parent 309a3f91a1
commit 2c5b3d0cc7
2 changed files with 12 additions and 8 deletions

View file

@ -149,7 +149,7 @@ impl ReadonlyRepo {
let operation_metadata =
crate::transaction::create_op_metadata(user_settings, "initialize repo".to_string());
let (op_heads_store, init_op) =
SimpleOpHeadsStore::init(op_heads_path, &op_store, &root_view, operation_metadata);
SimpleOpHeadsStore::init(&op_heads_path, &op_store, &root_view, operation_metadata);
let op_heads_store = Arc::new(op_heads_store);
let index_path = repo_path.join("index");
@ -406,7 +406,7 @@ impl RepoLoader {
let store = Store::new(store_factories.load_backend(&repo_path.join("store")));
let repo_settings = user_settings.with_repo(repo_path).unwrap();
let op_store = Arc::from(store_factories.load_op_store(&repo_path.join("op_store")));
let op_heads_store = Arc::new(SimpleOpHeadsStore::load(repo_path.join("op_heads")));
let op_heads_store = Arc::new(SimpleOpHeadsStore::load(&repo_path.join("op_heads")));
let index_store = Arc::new(IndexStore::load(repo_path.join("index")));
Self {
repo_path: repo_path.to_path_buf(),

View file

@ -14,7 +14,7 @@
use std::collections::HashSet;
use std::fmt::{Debug, Formatter};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use itertools::Itertools;
@ -62,7 +62,7 @@ impl LockedOpHeadsResolver for SimpleOpHeadsStoreLockResolver {
impl InnerSimpleOpHeadsStore {
pub fn init(
dir: PathBuf,
dir: &Path,
op_store: &Arc<dyn OpStore>,
root_view: &op_store::View,
operation_metadata: OperationMetadata,
@ -76,7 +76,9 @@ impl InnerSimpleOpHeadsStore {
let init_operation_id = op_store.write_operation(&init_operation).unwrap();
let init_operation = Operation::new(op_store.clone(), init_operation_id, init_operation);
let op_heads_store = InnerSimpleOpHeadsStore { dir };
let op_heads_store = InnerSimpleOpHeadsStore {
dir: dir.to_path_buf(),
};
op_heads_store.add_op_head(init_operation.id());
(op_heads_store, init_operation)
}
@ -125,7 +127,7 @@ impl InnerSimpleOpHeadsStore {
impl SimpleOpHeadsStore {
pub fn init(
dir: PathBuf,
dir: &Path,
op_store: &Arc<dyn OpStore>,
root_view: &op_store::View,
operation_metadata: OperationMetadata,
@ -140,9 +142,11 @@ impl SimpleOpHeadsStore {
)
}
pub fn load(dir: PathBuf) -> Self {
pub fn load(dir: &Path) -> Self {
SimpleOpHeadsStore {
store: Arc::new(InnerSimpleOpHeadsStore { dir }),
store: Arc::new(InnerSimpleOpHeadsStore {
dir: dir.to_path_buf(),
}),
}
}
}