mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 12:40:04 +00:00
Optimize fetch_crate_cratesio
using ManifestVisitor
and `download_tar_based_and_visit`. By using these two items, we avoid any I/O altogether. Everything happens in memory, thus there will be no i/o related errors or cost. This commit does not regress anything because `helpers::load_manifest_path` calls `Manifest::from_path_with_metadata`, which read in the whole `Cargo.toml` file at once. Thus this commit would not cause any OOM when the the original code would not. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
f3d3c488e3
commit
5bb5d12949
2 changed files with 14 additions and 20 deletions
|
@ -210,13 +210,14 @@ async fn entry() -> Result<()> {
|
|||
// Fetch crate via crates.io, git, or use a local manifest path
|
||||
// TODO: work out which of these to do based on `opts.name`
|
||||
// TODO: support git-based fetches (whole repo name rather than just crate name)
|
||||
let manifest_path = match opts.manifest_path.clone() {
|
||||
Some(p) => p,
|
||||
let manifest = match opts.manifest_path.clone() {
|
||||
Some(manifest_path) => {
|
||||
debug!("Reading manifest: {}", manifest_path.display());
|
||||
load_manifest_path(manifest_path.join("Cargo.toml"))?
|
||||
}
|
||||
None => fetch_crate_cratesio(&opts.name, &opts.version, temp_dir.path()).await?,
|
||||
};
|
||||
|
||||
debug!("Reading manifest: {}", manifest_path.display());
|
||||
let manifest = load_manifest_path(manifest_path.join("Cargo.toml"))?;
|
||||
let package = manifest.package.unwrap();
|
||||
|
||||
let is_plain_version = semver::Version::from_str(&opts.version).is_ok();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue