Fix updating metafiles: Skip on custom install path

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-22 22:59:02 +10:00
parent d21dde4889
commit 7bdc720a9a
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -241,6 +241,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
let desired_targets = get_desired_targets(&opts.targets); let desired_targets = get_desired_targets(&opts.targets);
// Compute install directory // Compute install directory
let custom_install_path = opts.install_path.is_some();
let install_path: Arc<Path> = Arc::from( let install_path: Arc<Path> = Arc::from(
get_install_path(opts.install_path.as_deref()).ok_or_else(|| { get_install_path(opts.install_path.as_deref()).ok_or_else(|| {
error!("No viable install path found of specified, try `--install-path`"); error!("No viable install path found of specified, try `--install-path`");
@ -338,27 +339,29 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
} }
block_in_place(|| { block_in_place(|| {
debug!("Writing .crates.toml"); if !custom_install_path {
metafiles::v1::CratesToml::append( debug!("Writing .crates.toml");
metadata_vec metafiles::v1::CratesToml::append(
.iter() metadata_vec
.map(|metadata| (&metadata.cvs, metadata.bins.clone())), .iter()
)?; .map(|metadata| (&metadata.cvs, metadata.bins.clone())),
)?;
debug!("Writing .crates2.json"); debug!("Writing .crates2.json");
metafiles::v2::Crates2Json::append(metadata_vec.into_iter().map(|metadata| { metafiles::v2::Crates2Json::append(metadata_vec.into_iter().map(|metadata| {
( (
metadata.cvs, metadata.cvs,
metafiles::v2::CrateInfo { metafiles::v2::CrateInfo {
version_req: Some(metadata.version_req), version_req: Some(metadata.version_req),
bins: metadata.bins, bins: metadata.bins,
profile: "release".into(), profile: "release".into(),
target: metadata.target, target: metadata.target,
rustc: format!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")), rustc: format!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")),
..Default::default() ..Default::default()
}, },
) )
}))?; }))?;
}
if opts.no_cleanup { if opts.no_cleanup {
// Consume temp_dir without removing it from fs. // Consume temp_dir without removing it from fs.