mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-31 08:02:56 +00:00

- Refactor: Mv fn `utils::asyncify` into mod `utils` - Improve err msg for task failure in `utils::asyncify` - Make sure `asyncify` always returns the same annoymous type that implements `Future` if the `T` is same. - Rewrite `extract_bin` to avoid `block_in_place` support cancellation by dropping - Rm unused dep scopeguard from binstalk-downloader - Rewrite `extract_tar_based_stream` so that it is cancellable by dropping - Unbox `extract_future` in `async_extracter::extract_zip` - Refactor `Download` API: Remove `CancellationFuture` as param since all futures returned by `Download::and_*` does not call `block_in_place`, so they can be cancelled by drop instead of using this cumbersome hack. - Fix exports from mod `async_tar_visitor` - Make `signal::{ignore_signals, wait_on_cancellation_signal}` private - Rm the global variable `CANCELLED` in `wait_on_cancellation_signal` and rm fn `wait_on_cancellation_signal_inner` - Optimize `wait_on_cancellation_signal`: Avoid `tokio::select!` on `not(unix)` - Rm unnecessary `tokio::select!` in `wait_on_cancellation_signal` on unix Since `unix::wait_on_cancellation_signal_unix` already waits for ctrl + c signal. - Optimize `extract_bin`: Send `Bytes` to blocking thread for zero-copy - Optimize `extract_with_blocking_decoder`: Avoid dup monomorphization - Box fut of `fetch_crate_cratesio` in `PackageInfo::resolve` - Optimize `extract_zip_entry`: Spawn only one blocking task per fn call by using a mspc queue for the data to be written to the `outfile`. This would improve efficiency as using `tokio::fs::File` is expensive: It spawns a new blocking task, which needs one heap allocation and then pushed to a mpmc queue, and then wait for it to be done on every loop. This also fix a race condition where the unix permission is set before the whole file is written, which might be used by attackers. - Optimize `extract_zip`: Use one `BytesMut` for entire extraction process To avoid frequent allocation and deallocation. - Optimize `extract_zip_entry`: Inc prob of reusing alloc in `BytesMut` Performs the reserve before sending the buf over mpsc queue to increase the possibility of reusing the previous allocation. NOTE: `BytesMut` only reuses the previous allocation if it is the only one holds the reference to it, which is either on the first allocation or all the `Bytes` in the mpsc queue has been consumed, written to the file and dropped. Since reading from entry would have to wait for external file I/O, this would give the blocking thread some time to flush `Bytes` out. - Disable unused feature fs of dep tokio Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
70 lines
2.5 KiB
TOML
70 lines
2.5 KiB
TOML
[package]
|
|
name = "binstalk-downloader"
|
|
description = "The binstall toolkit for downloading and extracting file"
|
|
repository = "https://github.com/cargo-bins/cargo-binstall"
|
|
documentation = "https://docs.rs/binstalk-downloader"
|
|
version = "0.1.0"
|
|
rust-version = "1.65.0"
|
|
authors = ["ryan <ryan@kurte.nz>"]
|
|
edition = "2021"
|
|
license = "GPL-3.0"
|
|
|
|
[dependencies]
|
|
async-trait = "0.1.59"
|
|
async-compression = { version = "0.3.15", features = ["gzip", "zstd", "xz", "bzip2", "tokio"] }
|
|
async_zip = { version = "0.0.9", features = ["deflate", "bzip2", "lzma", "zstd", "xz"] }
|
|
binstalk-types = { version = "0.1.0", path = "../binstalk-types" }
|
|
bytes = "1.3.0"
|
|
bzip2 = "0.4.3"
|
|
digest = "0.10.6"
|
|
flate2 = { version = "1.0.25", default-features = false }
|
|
futures-util = { version = "0.3.25", default-features = false, features = ["std"] }
|
|
generic-array = "0.14.6"
|
|
httpdate = "1.0.2"
|
|
reqwest = { version = "0.11.13", features = ["stream", "gzip", "brotli", "deflate"], default-features = false }
|
|
# Use a fork here since we need PAX support, but the upstream
|
|
# does not hav the PR merged yet.
|
|
#
|
|
#tar = "0.4.38"
|
|
tar = { package = "binstall-tar", version = "0.4.39" }
|
|
tempfile = "3.3.0"
|
|
thiserror = "1.0.37"
|
|
tokio = { version = "1.23.0", features = ["macros", "rt-multi-thread", "sync", "time", "fs"], default-features = false }
|
|
tokio-tar = "0.3.0"
|
|
tokio-util = { version = "0.7.4", features = ["io"] }
|
|
tower = { version = "0.4.13", features = ["limit", "util"] }
|
|
tracing = "0.1.37"
|
|
trust-dns-resolver = { version = "0.22.0", optional = true, default-features = false, features = ["dnssec-ring"] }
|
|
url = "2.3.1"
|
|
|
|
xz2 = "0.1.7"
|
|
|
|
# zstd is also depended by zip.
|
|
# Since zip 0.6.3 depends on zstd 0.11, we can use 0.12.0 here
|
|
# because it uses the same zstd-sys version.
|
|
# Otherwise there will be a link conflict.
|
|
zstd = { version = "0.12.1", default-features = false }
|
|
|
|
[features]
|
|
default = ["static", "rustls"]
|
|
|
|
static = ["bzip2/static", "xz2/static"]
|
|
pkg-config = ["zstd/pkg-config"]
|
|
|
|
zlib-ng = ["flate2/zlib-ng"]
|
|
|
|
rustls = [
|
|
"reqwest/rustls-tls",
|
|
|
|
# Enable the following features only if trust-dns-resolver is enabled.
|
|
"trust-dns-resolver?/dns-over-rustls",
|
|
# trust-dns-resolver currently supports https with rustls
|
|
"trust-dns-resolver?/dns-over-https-rustls",
|
|
"trust-dns-resolver?/dns-over-quic",
|
|
]
|
|
native-tls = ["reqwest/native-tls", "trust-dns-resolver?/dns-over-native-tls"]
|
|
|
|
# Enable trust-dns-resolver so that features on it will also be enabled.
|
|
trust-dns = ["trust-dns-resolver", "reqwest/trust-dns"]
|
|
|
|
zstd-thin = ["zstd/thin"]
|