Skip to content

Commit b716320

Browse files
committed
chore: revert to .unwrap() on mutex + fix stale doc reference (PR #460)
1 parent 16e07df commit b716320

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

crates/pet-hatch/src/lib.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ impl Locator for Hatch {
139139
));
140140
}
141141
}
142-
*self
143-
.workspace_virtual_dirs
144-
.lock()
145-
.unwrap_or_else(|p| p.into_inner()) = new_cache;
142+
*self.workspace_virtual_dirs.lock().unwrap() = new_cache;
146143
}
147144

148145
fn try_from(&self, env: &PythonEnv) -> Option<PythonEnvironment> {
@@ -180,10 +177,7 @@ impl Locator for Hatch {
180177
// unrelated virtualenvwrapper / `venv` env in the same directory
181178
// would be misclassified as Hatch-managed.
182179
if classification.is_none() {
183-
let cache = self
184-
.workspace_virtual_dirs
185-
.lock()
186-
.unwrap_or_else(|p| p.into_inner());
180+
let cache = self.workspace_virtual_dirs.lock().unwrap();
187181
'workspaces: for (workspace, virtual_dirs, matcher) in cache.iter() {
188182
for virtual_dir in virtual_dirs {
189183
if prefix_is_directly_under(&prefix, virtual_dir) {
@@ -240,11 +234,7 @@ impl Locator for Hatch {
240234
// 2. Walk project-local virtual directories for each configured workspace.
241235
// Apply the same env-name guard as `try_from()` so shared directories
242236
// (e.g. `~/.virtualenvs`) only yield the workspace's declared envs.
243-
let workspaces = self
244-
.workspace_virtual_dirs
245-
.lock()
246-
.unwrap_or_else(|p| p.into_inner())
247-
.clone();
237+
let workspaces = self.workspace_virtual_dirs.lock().unwrap().clone();
248238
for (workspace, virtual_dirs, matcher) in &workspaces {
249239
for virtual_dir in virtual_dirs {
250240
for env in find_envs_in_flat_dir(virtual_dir, Some(workspace.clone()), matcher) {
@@ -383,10 +373,12 @@ fn match_default_storage_layout(prefix: &Path, storage: &Path) -> Option<String>
383373

384374
/// True iff `prefix`'s parent equals `dir` (case-insensitive on Windows).
385375
///
386-
/// `dir` is expected to be already normalized via `norm_case()` (entries
387-
/// cached in `resolve_project_virtual_dirs()` always are), so we only
388-
/// normalize `prefix.parent()` here — avoiding redundant `GetLongPathNameW`
389-
/// / case-folding work on Windows in the identification hot path.
376+
/// `dir` is expected to be already normalized via `norm_case()` — entries
377+
/// cached on the `Hatch` locator are normalized at `configure()`-time by
378+
/// `resolve_virtual_paths_against_workspace()` (called from
379+
/// `resolve_workspace_hatch_config()`), so we only normalize
380+
/// `prefix.parent()` here — avoiding redundant `GetLongPathNameW` /
381+
/// case-folding work on Windows in the identification hot path.
390382
fn prefix_is_directly_under(prefix: &Path, dir: &Path) -> bool {
391383
match prefix.parent() {
392384
Some(parent) => norm_case(parent) == dir,

0 commit comments

Comments
 (0)