src/pxar/encoder.rs: refactor simple match statements to map_err()

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-07-01 17:36:08 +02:00 committed by Dietmar Maurer
parent 6e1c31163b
commit 0d70535a36

View File

@ -83,10 +83,8 @@ impl <'a, W: Write> Encoder<'a, W> {
// todo: use scandirat??
let dir_fd = dir.as_raw_fd();
let stat = match nix::sys::stat::fstat(dir_fd) {
Ok(stat) => stat,
Err(err) => bail!("fstat {:?} failed - {}", path, err),
};
let stat = nix::sys::stat::fstat(dir_fd)
.map_err(|err| format_err!("fstat {:?} failed - {}", path, err))?;
if !is_directory(&stat) {
bail!("got unexpected file type {:?} (not a directory)", path);