fix issue where we would attempt to remove ssl directory regardless of whether or not we created it (#664)

This commit is contained in:
Keagan McClelland
2021-10-13 14:34:47 -06:00
committed by Aiden McClelland
parent 516db0a3ba
commit c88bb11107

View File

@@ -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(|_| (