Make paths_map outlive transaction
@@ -7,6 +7,8 @@ lazy_static! {
static ref DB: std::sync::Mutex<Option<sled::Db>> = std::sync::Mutex::new(None);
static ref REF_CACHE: std::sync::Mutex<HashMap<git2::Oid, HashMap<git2::Oid, git2::Oid>>> =
std::sync::Mutex::new(HashMap::new());
+ static ref PATHS_MAP: std::sync::Mutex<HashMap<(git2::Oid, String), git2::Oid>> =
+ std::sync::Mutex::new(HashMap::new());
}
pub fn load(path: &std::path::Path) -> JoshResult<()> {
@@ -50,7 +52,6 @@ struct Transaction2 {
commit_map: HashMap<git2::Oid, HashMap<git2::Oid, git2::Oid>>,
apply_map: HashMap<git2::Oid, HashMap<git2::Oid, git2::Oid>>,
unapply_map: HashMap<git2::Oid, HashMap<git2::Oid, git2::Oid>>,
- paths_map: HashMap<(git2::Oid, String), git2::Oid>,
sled_trees: HashMap<git2::Oid, sled::Tree>,
missing: Vec<(filter::Filter, git2::Oid)>,
misses: usize,
@@ -88,7 +89,6 @@ impl Transaction {
commit_map: HashMap::new(),
apply_map: HashMap::new(),
unapply_map: HashMap::new(),
- paths_map: HashMap::new(),
sled_trees: HashMap::new(),
missing: vec![],
misses: 0,
@@ -150,8 +150,7 @@ impl Transaction {
}
pub fn insert_paths(&self, tree: (git2::Oid, String), result: git2::Oid) {
- let mut t2 = self.t2.borrow_mut();
- t2.paths_map.entry(tree).or_insert(result);
+ PATHS_MAP.lock().unwrap().entry(tree).or_insert(result);
}
pub fn insert_ref(&self, filter: filter::Filter, from: git2::Oid, to: git2::Oid) {
@@ -183,8 +182,7 @@ impl Transaction {
}
pub fn get_paths(&self, tree: (git2::Oid, String)) -> Option<git2::Oid> {
- let t2 = self.t2.borrow_mut();
- return t2.paths_map.get(&tree).cloned();
+ return PATHS_MAP.lock().unwrap().get(&tree).cloned();
}
pub fn insert(&self, filter: filter::Filter, from: git2::Oid, to: git2::Oid, store: bool) {
