Skip to content

Commit

Permalink
Fix incorrect binary link target (#665)
Browse files Browse the repository at this point in the history
Fix incorrect binary link target (#654)

When a proxy CLI'd command downloads a missing toolchain, multiple binary files within the downloaded distribution were being symlinked to the same one target file (thus overwriting each previous target).
  • Loading branch information
alfiedotwtf authored Oct 28, 2024
1 parent 51155e7 commit 3a60dec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,19 @@ impl Toolchain {
let store = Store::from_env()?;
for cfg in channel.build_download_configs() {
if store.has_component(&cfg.name, &cfg.version) {
hard_or_symlink_file(
&store
.component_dir_path(&cfg.name, &cfg.version)
.join(&cfg.name),
&self.bin_path.join(&cfg.name),
)?;
self.add_component(cfg)?;
} else {
let downloaded = store.install_component(&cfg)?;
for bin in downloaded {
hard_or_symlink_file(&bin, &self.bin_path.join(&cfg.name))?;
// Use the actual binary filename rather than the
// config name to prevent multiple binaries from
// being linked to the same target file.
match bin.file_name() {
None => bail!("Failed to read file '{bin:?}' from download"),
Some(executable) => {
hard_or_symlink_file(&bin, &self.bin_path.join(executable))?
}
}
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions tests/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,11 @@ fn direct_proxy_install_toolchain_in_store_publishable() {
}

#[test]
#[should_panic] // TODO: #654 will fix this
fn direct_proxy_install_toolchain_in_store_forc_plugin() {
test_direct_proxy_install_toolchain_in_store(Some("forc-client"));
}

#[test]
#[should_panic] // TODO: #654 will fix this
fn direct_proxy_install_toolchain_in_store_forc_plugin_external() {
test_direct_proxy_install_toolchain_in_store(Some("forc-tx"));
}
Expand All @@ -208,13 +206,11 @@ fn direct_proxy_install_toolchain_not_in_store_publishable() {
}

#[test]
#[should_panic] // TODO: #654 will fix this
fn direct_proxy_install_toolchain_not_in_store_forc_plugin() {
test_direct_proxy_install_toolchain_not_in_store(Some("forc-client"));
}

#[test]
#[should_panic] // TODO: #654 will fix this
fn direct_proxy_install_toolchain_not_in_store_forc_plugin_external() {
test_direct_proxy_install_toolchain_not_in_store(Some("forc-tx"));
}
Expand Down

0 comments on commit 3a60dec

Please sign in to comment.