mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 12:40:04 +00:00
Refactor: Extract new crate binstalk-bins
(#1294)
To reduce `binstalk` codegen and enable reuse of it. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
76c72469eb
commit
0c5a65fb35
14 changed files with 114 additions and 87 deletions
|
@ -261,7 +261,7 @@ async fn download_extract_and_verify(
|
|||
.iter()
|
||||
.zip(bin_files)
|
||||
.filter_map(|(bin, bin_file)| {
|
||||
match bin_file.check_source_exists(&extracted_files) {
|
||||
match bin_file.check_source_exists(&mut |p| extracted_files.has_file(p)) {
|
||||
Ok(()) => Some(Ok(bin_file)),
|
||||
|
||||
// This binary is optional
|
||||
|
@ -284,7 +284,8 @@ async fn download_extract_and_verify(
|
|||
}
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<bins::BinFile>, BinstallError>>()
|
||||
.collect::<Result<Vec<bins::BinFile>, bins::Error>>()
|
||||
.map_err(BinstallError::from)
|
||||
}
|
||||
|
||||
fn collect_bin_files(
|
||||
|
@ -314,7 +315,9 @@ fn collect_bin_files(
|
|||
.bin_dir
|
||||
.as_deref()
|
||||
.map(Cow::Borrowed)
|
||||
.unwrap_or_else(|| bins::infer_bin_dir_template(&bin_data, extracted_files));
|
||||
.unwrap_or_else(|| {
|
||||
bins::infer_bin_dir_template(&bin_data, &mut |p| extracted_files.get_dir(p).is_some())
|
||||
});
|
||||
|
||||
let template = Template::parse(&bin_dir)?;
|
||||
|
||||
|
@ -323,7 +326,7 @@ fn collect_bin_files(
|
|||
.binaries
|
||||
.iter()
|
||||
.map(|bin| bins::BinFile::new(&bin_data, bin.name.as_str(), &template, no_symlinks))
|
||||
.collect::<Result<Vec<_>, BinstallError>>()?;
|
||||
.collect::<Result<Vec<_>, bins::Error>>()?;
|
||||
|
||||
let mut source_set = BTreeSet::new();
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ impl Resolution {
|
|||
|
||||
impl ResolutionFetch {
|
||||
pub fn install(self, opts: &Options) -> Result<CrateInfo, BinstallError> {
|
||||
type InstallFp = fn(&bins::BinFile) -> Result<(), BinstallError>;
|
||||
type InstallFp = fn(&bins::BinFile) -> Result<(), bins::Error>;
|
||||
|
||||
let (install_bin, install_link): (InstallFp, InstallFp) = match (opts.no_track, opts.force)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue