From eac90fd113401be634538e32d9bbf6f66737aa70 Mon Sep 17 00:00:00 2001 From: Kevin Liao Date: Wed, 28 Jun 2023 11:40:54 -0700 Subject: [PATCH] Update init_external to return an error instead of unwrapping --- lib/src/git_backend.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/src/git_backend.rs b/lib/src/git_backend.rs index 971bdc36a..a5ffe2210 100644 --- a/lib/src/git_backend.rs +++ b/lib/src/git_backend.rs @@ -75,11 +75,9 @@ impl GitBackend { pub fn init_external(store_path: &Path, git_repo_path: &Path) -> Result { let extra_path = store_path.join("extra"); - std::fs::create_dir(&extra_path).unwrap(); - let mut git_target_file = File::create(store_path.join("git_target")).unwrap(); - git_target_file - .write_all(git_repo_path.to_str().unwrap().as_bytes()) - .unwrap(); + std::fs::create_dir(&extra_path)?; + let mut git_target_file = File::create(store_path.join("git_target"))?; + git_target_file.write_all(git_repo_path.to_str().unwrap().as_bytes())?; let repo = git2::Repository::open(store_path.join(git_repo_path)) .map_err(|err| BackendError::Other(format!("Failed to open git repository: {err}")))?; let extra_metadata_store = TableStore::init(extra_path, HASH_LENGTH);