Feature/fix no symlink (#432)

* Refactor `BinFile::from_product`: Simplify logic flow.
* Fix `--no-symlink` behavior

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-09-28 12:32:22 +10:00 committed by GitHub
parent e3cf3e9e3a
commit c15903684f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 48 deletions

View file

@ -238,6 +238,7 @@ async fn resolve_inner(
&package,
&install_path,
&binaries,
opts.no_symlinks,
)
.await
{
@ -281,6 +282,7 @@ async fn download_extract_and_verify(
package: &Package<Meta>,
install_path: &Path,
binaries: &[Product],
no_symlinks: bool,
) -> Result<Vec<bins::BinFile>, BinstallError> {
// Build final metadata
let meta = fetcher.target_meta();
@ -322,6 +324,7 @@ async fn download_extract_and_verify(
binaries,
bin_path.to_path_buf(),
install_path.to_path_buf(),
no_symlinks,
)?;
for bin_file in bin_files.iter() {
@ -340,6 +343,7 @@ fn collect_bin_files(
binaries: &[Product],
bin_path: PathBuf,
install_path: PathBuf,
no_symlinks: bool,
) -> Result<Vec<bins::BinFile>, BinstallError> {
// List files to be installed
// based on those found via Cargo.toml
@ -363,7 +367,7 @@ fn collect_bin_files(
// Create bin_files
let bin_files = binaries
.iter()
.map(|p| bins::BinFile::from_product(&bin_data, p, &bin_dir))
.map(|p| bins::BinFile::from_product(&bin_data, p, &bin_dir, no_symlinks))
.collect::<Result<Vec<_>, BinstallError>>()?;
let mut source_set = BTreeSet::new();