mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 20:48:43 +00:00
Skip crates that are already installed.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
04fee49c22
commit
ac085533cc
1 changed files with 24 additions and 2 deletions
26
src/main.rs
26
src/main.rs
|
@ -333,6 +333,25 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
||||||
fs::create_dir_all(&install_path).map_err(BinstallError::Io)?;
|
fs::create_dir_all(&install_path).map_err(BinstallError::Io)?;
|
||||||
debug!("Using install path: {}", install_path.display());
|
debug!("Using install path: {}", install_path.display());
|
||||||
|
|
||||||
|
// Load metadata
|
||||||
|
let metadata = if !custom_install_path {
|
||||||
|
debug!("Reading binstall/crates-v1.json");
|
||||||
|
Some(metafiles::binstall_v1::Records::load()?)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
// Filter out installed crate_names
|
||||||
|
let crate_names = crate_names.filter(|crate_name| {
|
||||||
|
if opts.force {
|
||||||
|
true
|
||||||
|
} else if let Some(records) = &metadata {
|
||||||
|
!records.contains(&crate_name.name)
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Create a temporary directory for downloads etc.
|
// Create a temporary directory for downloads etc.
|
||||||
//
|
//
|
||||||
// Put all binaries to a temporary directory under `dst` first, catching
|
// Put all binaries to a temporary directory under `dst` first, catching
|
||||||
|
@ -429,7 +448,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
block_in_place(|| {
|
block_in_place(|| {
|
||||||
if !custom_install_path {
|
if let Some(mut records) = metadata {
|
||||||
// If using standardised install path,
|
// If using standardised install path,
|
||||||
// then create_dir_all(&install_path) would also
|
// then create_dir_all(&install_path) would also
|
||||||
// create .cargo.
|
// create .cargo.
|
||||||
|
@ -438,7 +457,10 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
||||||
metafiles::v1::CratesToml::append(metadata_vec.iter())?;
|
metafiles::v1::CratesToml::append(metadata_vec.iter())?;
|
||||||
|
|
||||||
debug!("Writing binstall/crates-v1.json");
|
debug!("Writing binstall/crates-v1.json");
|
||||||
metafiles::binstall_v1::append(metadata_vec)?;
|
for metadata in metadata_vec {
|
||||||
|
records.replace(metadata);
|
||||||
|
}
|
||||||
|
records.overwrite()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.no_cleanup {
|
if opts.no_cleanup {
|
||||||
|
|
Loading…
Add table
Reference in a new issue