Skip to content

Commit

Permalink
cleanup: propagate some errors up when failing to write to file
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonz committed Jul 24, 2021
1 parent d6a1f98 commit a141142
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/index_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/local_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Store for LocalStore {

fn write_symlink(&self, _path: &RepoPath, target: &str) -> Result<SymlinkId, StoreError> {
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());
Expand Down

0 comments on commit a141142

Please sign in to comment.