From 90f0a8ded4ac9a07f19d4c57f48a6a0979651a6b Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 13 Sep 2023 15:27:04 +0200 Subject: [PATCH] ignore error when directory creation fails with AlreadyExists --- src/apply_indexchanges.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/apply_indexchanges.rs b/src/apply_indexchanges.rs index 6c21584..306e542 100755 --- a/src/apply_indexchanges.rs +++ b/src/apply_indexchanges.rs @@ -33,7 +33,13 @@ pub fn apply_indexchanges_int( match change { IndexChange::AddDir(dir) => { let t = target.join(dir); - if let Err(e) = fs::create_dir(&t) { + if let Some(e) = fs::create_dir(&t).err().and_then(|e| { + if matches!(e.kind(), io::ErrorKind::AlreadyExists) { + None + } else { + Some(e) + } + }) { eprintln!("\n[warn] couldn't create directory {t:?}: {e}"); } else { fs::create_dir(&index.join(dir))?;