From 2c5b3d0cc7da37c0d2e3d7c107b5d1b6808eeb44 Mon Sep 17 00:00:00 2001 From: Daniel Ploch Date: Thu, 15 Dec 2022 18:53:43 -0500 Subject: [PATCH] op_heads_store: convert load() to take &Path like other factories --- lib/src/repo.rs | 4 ++-- lib/src/simple_op_heads_store.rs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 540a5397b..4d1331ef3 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -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(), diff --git a/lib/src/simple_op_heads_store.rs b/lib/src/simple_op_heads_store.rs index 3d0b278cf..97ed00810 100644 --- a/lib/src/simple_op_heads_store.rs +++ b/lib/src/simple_op_heads_store.rs @@ -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, 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, 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(), + }), } } }