return Result<()> instead of unwrap() when decompressing to catch the error

This commit is contained in:
ALEZ-DEV 2024-05-31 00:10:06 +02:00
parent 4d07600ea6
commit 7ed53c752f

View File

@ -81,18 +81,16 @@ impl ComponentDownloader for ProtonComponent {
let tar_xz = File::open(file.clone()).unwrap(); let tar_xz = File::open(file.clone()).unwrap();
let tar = GzDecoder::new(tar_xz); let tar = GzDecoder::new(tar_xz);
let mut archive = Archive::new(tar); let mut archive = Archive::new(tar);
archive archive.unpack(new_directory_name.parent().unwrap())?;
.unpack(new_directory_name.parent().unwrap()) remove_file(file.clone())?;
.unwrap();
remove_file(file.clone()).unwrap();
rename( rename(
file.to_str().unwrap().strip_suffix(".tar.gz").unwrap(), file.to_str().unwrap().strip_suffix(".tar.gz").unwrap(),
new_directory_name, new_directory_name,
) )?;
.unwrap();
Ok::<(), anyhow::Error>(())
}) })
.await .await??;
.unwrap();
Ok(()) Ok(())
} }