Skip to content

Commit a28c9b3

Browse files
committed
better error handling on close (#301)
There is still some work to be done to deal with all the special errors we see now for some reason.
1 parent c7e1400 commit a28c9b3

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

git-worktree/src/index/checkout.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ pub enum Error<E: std::error::Error + Send + Sync + 'static> {
219219
Time(#[from] std::time::SystemTimeError),
220220
#[error("IO error while writing blob or reading file metadata or changing filetype")]
221221
Io(#[from] std::io::Error),
222-
#[error(transparent)]
223-
FileClose(#[from] close_file::CloseError),
224222
#[error("object {} for checkout at {} could not be retrieved from object database", .oid.to_hex(), .path.display())]
225223
Find {
226224
#[source]

git-worktree/src/index/entry.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ where
7070
// NOTE: we don't call `file.sync_all()` here knowing that some filesystems don't handle this well.
7171
// revisit this once there is a bug to fix.
7272
update_fstat(entry, file.metadata()?)?;
73-
// file.close()?;
73+
file.close().map_err(|err| err.unwrap() /* misnomer, won't panic */)?;
7474
obj.data.len()
7575
}
7676
git_index::entry::Mode::SYMLINK => {
@@ -91,7 +91,8 @@ where
9191
open_options(p, destination_is_initially_empty, overwrite_existing).open(&dest)
9292
})?;
9393
file.write_all(obj.data)?;
94-
file.close()?;
94+
file.close()
95+
.map_err(|err| err.unwrap() /* misnomer for 'into inner' */)?;
9596
}
9697

9798
update_fstat(entry, std::fs::symlink_metadata(&dest)?)?;

0 commit comments

Comments
 (0)