From c88bb1110716efc5a92085fc5b0095b26af03715 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Wed, 13 Oct 2021 14:34:47 -0600 Subject: [PATCH] fix issue where we would attempt to remove ssl directory regardless of whether or not we created it (#664) --- appmgr/src/net/nginx.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/appmgr/src/net/nginx.rs b/appmgr/src/net/nginx.rs index 1cdf2362c..42338ae62 100644 --- a/appmgr/src/net/nginx.rs +++ b/appmgr/src/net/nginx.rs @@ -198,8 +198,20 @@ impl NginxControllerInner { let available_path = nginx_root.join(format!("sites-available/{}_{}.conf", package, id)); let _ = futures::try_join!( - tokio::fs::remove_dir_all(&package_path).map(|res| res - .with_ctx(|_| (ErrorKind::Filesystem, package_path.display().to_string()))), + async { + if tokio::fs::metadata(&package_path).await.is_ok() { + tokio::fs::remove_dir_all(&package_path) + .map(|res| { + res.with_ctx(|_| { + (ErrorKind::Filesystem, package_path.display().to_string()) + }) + }) + .await?; + Ok(()) + } else { + Ok(()) + } + }, tokio::fs::remove_file(&enabled_path).map(|res| res .with_ctx(|_| (ErrorKind::Filesystem, enabled_path.display().to_string()))), tokio::fs::remove_file(&available_path).map(|res| res.with_ctx(|_| (