From 00882e31fc6c46d39207633f6f8e32f13c44b1bb Mon Sep 17 00:00:00 2001 From: John Mumm Date: Tue, 22 Jul 2025 20:19:22 +0200 Subject: [PATCH] Ignore empty directory if not allow_existing --- crates/uv-virtualenv/src/virtualenv.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/uv-virtualenv/src/virtualenv.rs b/crates/uv-virtualenv/src/virtualenv.rs index 2227b71b9..2aa1baf0c 100644 --- a/crates/uv-virtualenv/src/virtualenv.rs +++ b/crates/uv-virtualenv/src/virtualenv.rs @@ -95,18 +95,17 @@ pub(crate) fn create( OnExisting::Allow => { debug!("Allowing existing {name} due to `--allow-existing`"); } + _ if location + .read_dir() + .is_ok_and(|mut dir| dir.next().is_none()) => + { + debug!("Ignoring empty directory"); + } OnExisting::Remove => { debug!("Removing existing {name} due to `--clear`"); remove_virtualenv(location)?; fs::create_dir_all(location)?; } - OnExisting::Fail - if location - .read_dir() - .is_ok_and(|mut dir| dir.next().is_none()) => - { - debug!("Ignoring empty directory"); - } OnExisting::Fail => { match confirm_clear(location, name)? { Some(true) => {