From a14114256e76a0678d3735b3136f692de3a66b7c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 13 Jun 2021 22:35:10 -0700 Subject: [PATCH] cleanup: propagate some errors up when failing to write to file --- lib/src/index.rs | 2 +- lib/src/index_store.rs | 2 +- lib/src/local_store.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/index.rs b/lib/src/index.rs index 0bd89ccb7..bc9d7b757 100644 --- a/lib/src/index.rs +++ b/lib/src/index.rs @@ -617,7 +617,7 @@ impl MutableIndex { let mut temp_file = NamedTempFile::new_in(&dir)?; let file = temp_file.as_file_mut(); - file.write_all(&buf).unwrap(); + file.write_all(&buf)?; persist_content_addressed_temp_file(temp_file, &index_file_path)?; let mut cursor = Cursor::new(&buf); diff --git a/lib/src/index_store.rs b/lib/src/index_store.rs index 978e439df..836ad7292 100644 --- a/lib/src/index_store.rs +++ b/lib/src/index_store.rs @@ -151,7 +151,7 @@ impl IndexStore { ) -> io::Result<()> { let mut temp_file = NamedTempFile::new_in(&self.dir)?; let file = temp_file.as_file_mut(); - file.write_all(index.name().as_bytes()).unwrap(); + file.write_all(index.name().as_bytes())?; persist_content_addressed_temp_file( temp_file, &self.dir.join("operations").join(op_id.hex()), diff --git a/lib/src/local_store.rs b/lib/src/local_store.rs index 6b0d60c42..3915b5860 100644 --- a/lib/src/local_store.rs +++ b/lib/src/local_store.rs @@ -155,7 +155,7 @@ impl Store for LocalStore { fn write_symlink(&self, _path: &RepoPath, target: &str) -> Result { let mut temp_file = NamedTempFile::new_in(&self.path)?; - temp_file.write_all(target.as_bytes()).unwrap(); + temp_file.write_all(target.as_bytes())?; let mut hasher = Blake2b::new(); hasher.update(&target.as_bytes()); let id = SymlinkId(hasher.finalize().to_vec());