diff --git a/src/origin/store/git.rs b/src/origin/store/git.rs index 52367c1..ff12273 100644 --- a/src/origin/store/git.rs +++ b/src/origin/store/git.rs @@ -4,13 +4,14 @@ use crate::origin::{self, store}; use std::path::{Path, PathBuf}; use std::{collections, fs, io, sync}; +#[derive(Clone)] struct Origin { descr: origin::Descr, - repo: gix::ThreadSafeRepository, + repo: sync::Arc, tree_object_id: gix::ObjectId, } -impl origin::Origin for sync::Arc { +impl origin::Origin for Origin { fn descr(&self) -> &origin::Descr { &self.descr } @@ -67,7 +68,7 @@ struct Store { // more than one origin to be syncing at a time sync_guard: sync::Mutex>, - origins: sync::RwLock>>, + origins: sync::RwLock>, } pub fn new(dir_path: PathBuf) -> io::Result { @@ -96,7 +97,7 @@ impl Store { &self, repo: gix::Repository, descr: origin::Descr, - ) -> Result, GetOriginError> { + ) -> Result { let origin::Descr::Git { ref branch_name, .. } = descr; @@ -118,11 +119,11 @@ impl Store { .map_unexpected_while(|| format!("parsing {commit_object_id} as commit"))? .tree(); - Ok(sync::Arc::from(Origin { + Ok(Origin { descr, - repo: repo.into(), + repo: sync::Arc::new(repo.into()), tree_object_id, - })) + }) } fn sync_inner( @@ -210,7 +211,7 @@ impl Store { impl super::BoxedStore for sync::Arc {} impl super::Store for sync::Arc { - type Origin<'store> = sync::Arc + type Origin<'store> = Origin where Self: 'store; type AllDescrsIter<'store> = Box> + 'store>