From 8a0fcfb032ea79e75566202f9d5ac3708140df7e Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 19 May 2023 18:32:12 +0900 Subject: [PATCH] git_backend: leverage read_extra_metadata_table() in write_commit() And use the readonly table for lookup, which allows us to extract a helper method to add/save entry. --- lib/src/git_backend.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index 2b119b051..aa2d08ece 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -513,11 +513,8 @@ impl Backend for GitBackend { } let parent_refs = parents.iter().collect_vec(); let extras = serialize_extras(&contents); - let mut mut_table = self - .extra_metadata_store - .get_head() - .unwrap() - .start_mutation(); + let table = self.read_extra_metadata_table()?; + let mut mut_table = table.start_mutation(); let id = loop { let git_id = locked_repo .commit( @@ -533,7 +530,7 @@ impl Backend for GitBackend { source: Box::new(err), })?; let id = CommitId::from_bytes(git_id.as_bytes()); - match mut_table.get_value(id.as_bytes()) { + match table.get_value(id.as_bytes()) { Some(existing_extras) if existing_extras != extras => { // It's possible a commit already exists with the same commit id but different // change id. Adjust the timestamp until this is no longer the case.