Collapse nested if
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
b0af48aa03
commit
787cb3a872
|
|
@ -246,11 +246,9 @@ impl Checkout {
|
||||||
.map_err(|err| CheckoutFailure::Payload { rid, err })?;
|
.map_err(|err| CheckoutFailure::Payload { rid, err })?;
|
||||||
let path = directory.unwrap_or_else(|| PathBuf::from(proj.name()));
|
let path = directory.unwrap_or_else(|| PathBuf::from(proj.name()));
|
||||||
// N.b. fail if the path exists and is not empty
|
// N.b. fail if the path exists and is not empty
|
||||||
if path.exists() {
|
if path.exists() && path.read_dir().map_or(true, |mut dir| dir.next().is_some()) {
|
||||||
if path.read_dir().map_or(true, |mut dir| dir.next().is_some()) {
|
|
||||||
return Err(CheckoutFailure::Exists { rid, path });
|
return Err(CheckoutFailure::Exists { rid, path });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id: rid,
|
id: rid,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue