Skip to content

Commit ecee2d2

Browse files
committed
Use XZ compression instead of Gzip on Node download
1 parent 5957b7c commit ecee2d2

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

Cargo.lock

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lto = "fat"
1212

1313
[dependencies]
1414
anyhow = "1.0.86"
15-
async-compression = { version = "0.4.11", features = ["gzip", "tokio"] }
15+
async-compression = { version = "0.4.11", features = ["xz", "tokio"] }
1616
clap = { version = "4.5.8", features = ["derive"] }
1717
dircpy = "0.3.16"
1818
dirs = "5.0.1"

src/types/node/release.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{exts::HyperlinkExt, types};
2-
use async_compression::tokio::bufread::GzipDecoder;
2+
use async_compression::tokio::bufread::XzDecoder;
33
use futures::TryStreamExt;
44
use indicatif::{ProgressBar, ProgressStyle};
55
use serde::{de::Error as DeError, Deserialize, Deserializer};
@@ -50,9 +50,7 @@ impl NodeRelease {
5050
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err));
5151

5252
let unpack_temporary_folder = types::temp::Folder::new()?;
53-
// TODO: Use `XzDecoder` since its the default NodeJS website downloads for Linux.
54-
// It's also smaller than Gzip.
55-
let decompressed = GzipDecoder::new(BufReader::new(StreamReader::new(data_stream)));
53+
let decompressed = XzDecoder::new(BufReader::new(StreamReader::new(data_stream)));
5654
Archive::new(decompressed)
5755
.unpack(unpack_temporary_folder.path())
5856
.await?;
@@ -72,7 +70,7 @@ impl NodeRelease {
7270

7371
pub fn get_download_url(&self) -> String {
7472
format!(
75-
"{}/v{}/{}.tar.gz",
73+
"{}/v{}/{}.tar.xz",
7674
types::node::URLs::default().get_distribution_path(),
7775
self.version,
7876
self.get_archive_string()
@@ -96,10 +94,8 @@ impl NodeRelease {
9694
}
9795

9896
pub fn is_supported_by_current_platform(&self) -> bool {
99-
// TODO: ???
100-
self.files.iter().any(|file| {
101-
file.contains(&types::platforms::Platform::get_system_platform().to_string())
102-
})
97+
self.files
98+
.contains(&types::platforms::Platform::get_system_platform().to_string())
10399
}
104100
}
105101

0 commit comments

Comments
 (0)