Skip to content

Commit 82feff9

Browse files
karthiknadigCopilot
andcommitted
fix: normalize Conda environment cache keys (PR #487)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3ff38d5 commit 82feff9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

crates/pet-conda/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,14 @@ impl Conda {
172172
where
173173
F: FnOnce() -> Option<CondaEnvironmentDetails>,
174174
{
175+
let cache_key = norm_case(path);
175176
let fingerprint_before = CondaEnvironmentFingerprint::from_prefix(path);
176177
if let Some(fingerprint) = &fingerprint_before {
177178
if let Some(cached) = self
178179
.environment_info_cache
179180
.read()
180181
.expect("conda environment info cache lock poisoned")
181-
.get(path)
182+
.get(&cache_key)
182183
.filter(|cached| &cached.fingerprint == fingerprint)
183184
{
184185
return Some(cached.details.clone());
@@ -189,7 +190,7 @@ impl Conda {
189190
self.environment_info_cache
190191
.write()
191192
.expect("conda environment info cache lock poisoned")
192-
.remove(path);
193+
.remove(&cache_key);
193194
return None;
194195
};
195196
let fingerprint_after = CondaEnvironmentFingerprint::from_prefix(path);
@@ -199,14 +200,14 @@ impl Conda {
199200
.expect("conda environment info cache lock poisoned");
200201
if fingerprint_before.is_some() && fingerprint_before == fingerprint_after {
201202
cache.insert(
202-
path.to_path_buf(),
203+
cache_key,
203204
CachedCondaEnvironment {
204205
fingerprint: fingerprint_after.expect("fingerprint checked as present"),
205206
details: details.clone(),
206207
},
207208
);
208209
} else {
209-
cache.remove(path);
210+
cache.remove(&cache_key);
210211
}
211212

212213
Some(details)
@@ -458,7 +459,8 @@ impl Locator for Conda {
458459
}
459460

460461
let possible_conda_envs = get_conda_environment_paths(&env_vars, &executable);
461-
let active_prefixes: HashSet<PathBuf> = possible_conda_envs.iter().cloned().collect();
462+
let active_prefixes: HashSet<PathBuf> =
463+
possible_conda_envs.iter().map(norm_case).collect();
462464
for path in possible_conda_envs {
463465
s.spawn(move || {
464466
let details = self.get_environment_details(&path)?;

0 commit comments

Comments
 (0)