Ignore empty directory if not allow_existing

This commit is contained in:
John Mumm 2025-07-22 20:19:22 +02:00
parent f0151f3a18
commit 00882e31fc
No known key found for this signature in database
GPG Key ID: 73D2271AFDC26EA8
1 changed files with 6 additions and 7 deletions

View File

@ -95,18 +95,17 @@ pub(crate) fn create(
OnExisting::Allow => { OnExisting::Allow => {
debug!("Allowing existing {name} due to `--allow-existing`"); debug!("Allowing existing {name} due to `--allow-existing`");
} }
OnExisting::Remove => { _ if location
debug!("Removing existing {name} due to `--clear`");
remove_virtualenv(location)?;
fs::create_dir_all(location)?;
}
OnExisting::Fail
if location
.read_dir() .read_dir()
.is_ok_and(|mut dir| dir.next().is_none()) => .is_ok_and(|mut dir| dir.next().is_none()) =>
{ {
debug!("Ignoring empty directory"); debug!("Ignoring empty directory");
} }
OnExisting::Remove => {
debug!("Removing existing {name} due to `--clear`");
remove_virtualenv(location)?;
fs::create_dir_all(location)?;
}
OnExisting::Fail => { OnExisting::Fail => {
match confirm_clear(location, name)? { match confirm_clear(location, name)? {
Some(true) => { Some(true) => {