Skip to content

Commit

Permalink
Update src/lock_file/update.rs
Browse files Browse the repository at this point in the history
Co-authored-by: nichmor <[email protected]>
  • Loading branch information
Hofer-Julian and nichmor committed Dec 6, 2024
1 parent 528e3d1 commit 2b2a856
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/lock_file/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,30 @@ impl<'p> LockFileDerivedData<'p> {
environment: &Environment<'p>,
hash: &LockedEnvironmentHash,
) -> Option<Result<Prefix, Report>> {
if let Ok(Some(environment_file)) = read_environment_file(&environment.dir()) {
if environment_file.environment_lock_file_hash == *hash {
let contains_source_packages = self.lock_file.environments().any(|(_, env)| {
env.conda_packages(Platform::current())
.map_or(false, |mut packages| {
packages.any(|package| package.as_source().is_some())
})
});
if contains_source_packages {
tracing::debug!("Lock file contains source packages: ignore lock file hash and update the prefix");
} else {
tracing::info!(
"Environment '{}' is up-to-date with lock file hash",
environment.name().fancy_display()
);
return Some(Ok(Prefix::new(environment.dir())));
}
}
} else {
let Ok(Some(environment_file)) = read_environment_file(&environment.dir()) else {
tracing::debug!(
"Environment file not found or parsable for '{}'",
environment.name().fancy_display()
);
return None;
};

if environment_file.environment_lock_file_hash == *hash {
let contains_source_packages = self.lock_file.environments().any(|(_, env)| {
env.conda_packages(Platform::current())
.map_or(false, |mut packages| {
packages.any(|package| package.as_source().is_some())
})
});
if contains_source_packages {
tracing::debug!("Lock file contains source packages: ignore lock file hash and update the prefix");
} else {
tracing::info!(
"Environment '{}' is up-to-date with lock file hash",
environment.name().fancy_display()
);
return Some(Ok(Prefix::new(environment.dir())));
}
}
None
}
Expand Down

0 comments on commit 2b2a856

Please sign in to comment.