Skip to content

Commit b4e9149

Browse files
committed
find_micromamba_in_archive: simplify paths a bit
1 parent 1680aa0 commit b4e9149

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/micromamba/download.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use log::{debug, info};
44
use std::fmt;
55
use std::fs;
66
use std::io::{self, Read};
7-
use std::path::{Path, PathBuf};
7+
use std::path::PathBuf;
88

99
pub enum DownloadError {
1010
IncompatibleOS,
@@ -121,18 +121,20 @@ fn write_micromamba<R: Read>(
121121
fn find_micromamba_in_archive<'a, R: Read>(
122122
tar_archive: &'a mut tar::Archive<R>,
123123
) -> Result<tar::Entry<'a, R>, DownloadError> {
124-
let archive_binary_path = if cfg!(target_os = "linux") {
125-
Path::new("bin").join("micromamba")
124+
let archive_binary_dir = if cfg!(target_os = "linux") {
125+
PathBuf::from("bin")
126126
} else if cfg!(target_os = "windows") {
127-
Path::new("Library").join("bin").join("micromamba.exe")
127+
PathBuf::from("Library").join("bin")
128128
} else {
129129
return Err(DownloadError::IncompatibleOS);
130130
};
131131

132+
let micromamba_exe = micromamba_executable_name()?;
133+
132134
for entry in tar_archive.entries()? {
133135
let entry = entry?;
134136
if let Ok(path) = entry.path()
135-
&& path == archive_binary_path
137+
&& path == archive_binary_dir.join(micromamba_exe)
136138
{
137139
return Ok(entry);
138140
}

0 commit comments

Comments
 (0)