cleanup: propagate some errors up when failing to write to file

This commit is contained in:
Martin von Zweigbergk 2021-06-13 22:35:10 -07:00
parent d6a1f9848a
commit a14114256e
3 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -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()),

View File

@ -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());