Replaces fs-err in untar_snapshot_create_shared_buffer() (#34905)

This commit is contained in:
Brooks 2024-01-23 12:46:31 -05:00 committed by GitHub
parent 4bd8eedc06
commit a21cfbd13f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -1977,7 +1977,16 @@ fn untar_snapshot_create_shared_buffer(
snapshot_tar: &Path,
archive_format: ArchiveFormat,
) -> SharedBuffer {
let open_file = || fs_err::File::open(snapshot_tar).unwrap();
let open_file = || {
fs::File::open(snapshot_tar)
.map_err(|err| {
IoError::other(format!(
"failed to open snapshot archive '{}': {err}",
snapshot_tar.display(),
))
})
.unwrap()
};
match archive_format {
ArchiveFormat::TarBzip2 => SharedBuffer::new(BzDecoder::new(BufReader::new(open_file()))),
ArchiveFormat::TarGzip => SharedBuffer::new(GzDecoder::new(BufReader::new(open_file()))),