Skip to content

Commit

Permalink
Fix for gz file trying to be extracted as a tar archive (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
d10sfan authored Dec 2, 2023
1 parent 774e618 commit 106575e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ fn unpack_tarball(
.and_then(OsStr::to_str)
.unwrap_or("");

let file_name = Path::new(&tarball)
.file_name()
.and_then(OsStr::to_str)
.unwrap_or("");

if let Some(file_download_config) = game_info.find_download_config_by_name(name) {
if let Some(tmp_extract_location) = file_download_config.extract_location {
extract_location = tmp_extract_location;
Expand Down Expand Up @@ -347,7 +352,9 @@ fn unpack_tarball(

if file_extension == "bz2" {
decoder = Box::new(BzDecoder::new(file));
} else if file_extension == "gz" || file_extension == "tgz" {
} else if (file_extension == "gz" && file_name.contains(".tar.gz"))
|| file_extension == "tgz"
{
decoder = Box::new(GzDecoder::new(file));
} else if file_extension == "xz" {
decoder = Box::new(XzDecoder::new(file));
Expand Down

0 comments on commit 106575e

Please sign in to comment.