From 7b408768ca4a67687762d55ab2031e183c274cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bardon?= Date: Fri, 9 Aug 2024 00:20:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20`fs::remove=5Fdir=5Fall`=20is=20?= =?UTF-8?q?not=20idempotent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cargo.lock | 2 +- src/helpers/src/generate.rs | 4 +++- src/orangutan-server/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 73a0370..869b34c 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "orangutan-server" -version = "0.4.8" +version = "0.4.9" dependencies = [ "base64 0.22.1", "biscuit-auth", diff --git a/src/helpers/src/generate.rs b/src/helpers/src/generate.rs index 70ce308..1f68a1b 100644 --- a/src/helpers/src/generate.rs +++ b/src/helpers/src/generate.rs @@ -361,7 +361,9 @@ pub fn trash_outdated_websites() -> Result { // NOTE: This whould not be necessary since the directory should be deleted // but there might be edge cases where it's still there and the next // `fs::rename` will fail if it's the case. - fs::remove_dir_all(TRASH_DIR.as_path())?; + if TRASH_DIR.exists() { + fs::remove_dir_all(TRASH_DIR.as_path())?; + } // Remove outdated websites fs::rename(DEST_DIR.as_path(), TRASH_DIR.as_path())?; diff --git a/src/orangutan-server/Cargo.toml b/src/orangutan-server/Cargo.toml index e594db3..8a7ac44 100644 --- a/src/orangutan-server/Cargo.toml +++ b/src/orangutan-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orangutan-server" -version = "0.4.8" +version = "0.4.9" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html