|
| 1 | +use crate::csmrc::Config; |
1 | 2 | use crate::env::dump_micromamba_captured_output_on_error; |
2 | 3 | use crate::micromamba::Micromamba; |
3 | 4 |
|
@@ -28,7 +29,7 @@ fn archive_name_to_env_name(archive_path: &Path) -> Option<String> { |
28 | 29 | .map(String::from) |
29 | 30 | } |
30 | 31 |
|
31 | | -pub fn run(micromamba: Micromamba, args: Args) -> Result<(), ExitCode> { |
| 32 | +pub fn run(micromamba: Micromamba, args: Args, config: &Config) -> Result<(), ExitCode> { |
32 | 33 | let env_name = match args.name { |
33 | 34 | Some(name) => name, |
34 | 35 | None => match archive_name_to_env_name(&args.archive_path) { |
@@ -69,19 +70,22 @@ pub fn run(micromamba: Micromamba, args: Args) -> Result<(), ExitCode> { |
69 | 70 | })?; |
70 | 71 | let decompressor = flate2::read::GzDecoder::new(archive_file); |
71 | 72 | let mut archive = tar::Archive::new(decompressor); |
72 | | - archive.unpack(&target_env_path).map_err(|e| { |
73 | | - error!( |
74 | | - "Could not unpack archive to '{}': {}", |
75 | | - target_env_path.display(), |
76 | | - e |
| 73 | + if config.noop_mode { |
| 74 | + info!("Prepared to unpack the environment. Not actually extracting, due to no-op mode."); |
| 75 | + } else { |
| 76 | + archive.unpack(&target_env_path).map_err(|e| { |
| 77 | + error!( |
| 78 | + "Could not unpack archive to '{}': {}", |
| 79 | + target_env_path.display(), |
| 80 | + e |
| 81 | + ); |
| 82 | + ExitCode::FAILURE |
| 83 | + })?; |
| 84 | + info!( |
| 85 | + "Successfully unpacked environment to '{}'", |
| 86 | + target_env_path.display() |
77 | 87 | ); |
78 | | - ExitCode::FAILURE |
79 | | - })?; |
80 | | - info!( |
81 | | - "Successfully unpacked environment to '{}'", |
82 | | - target_env_path.display() |
83 | | - ); |
84 | | - |
| 88 | + } |
85 | 89 | info!("Running 'conda-unpack' in the new environment to fix paths..."); |
86 | 90 | let result = micromamba.stream_if_verbose(vec!["run", "--name", &env_name, "conda-unpack"]); |
87 | 91 | let rc = result.exit_code(); |
|
0 commit comments