appmgr: fix deleted certs

This commit is contained in:
Aiden McClelland
2021-03-02 15:15:27 -07:00
committed by Aiden McClelland
parent 9f47a34b11
commit 6b3fa54551
2 changed files with 9 additions and 13 deletions

View File

@@ -262,12 +262,12 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
crate::PERSISTENCE_DIR,
manifest.id
);
tokio::fs::create_dir_all(
Path::new(crate::PERSISTENCE_DIR)
.join("apps")
.join(&manifest.id),
)
.await?;
let app_dir = PersistencePath::from_ref("apps").join(&manifest.id);
let app_dir_path = app_dir.path();
if app_dir_path.exists() {
tokio::fs::remove_dir_all(&app_dir_path).await?;
}
tokio::fs::create_dir_all(&app_dir_path).await?;
let (ip, tor_addr, tor_key) = crate::tor::set_svc(
&manifest.id,
@@ -283,12 +283,6 @@ pub async fn install_v0<R: AsyncRead + Unpin + Send + Sync>(
log::info!("Creating volume {}/{}.", crate::VOLUMES, manifest.id);
tokio::fs::create_dir_all(Path::new(crate::VOLUMES).join(&manifest.id)).await?;
let app_dir = PersistencePath::from_ref("apps").join(&manifest.id);
let app_dir_path = app_dir.path();
if app_dir_path.exists() {
tokio::fs::remove_dir_all(&app_dir_path).await?;
}
tokio::fs::create_dir_all(&app_dir_path).await?;
let _lock = app_dir.lock(true).await?;
log::info!("Saving manifest.");
let mut manifest_out = app_dir.join("manifest.yaml").write(None).await?;

View File

@@ -234,7 +234,7 @@ pub async fn write_lan_services(hidden_services: &ServicesMap) -> Result<(), Err
for mapping in &service.ports {
match &mapping.lan {
Some(LanOptions::Standard) => {
log::info!("Writing LAN certificates");
log::info!("Writing LAN certificates for {}", app_id);
let base_path = PersistencePath::from_ref("apps").join(&app_id);
let key_path = base_path.join("cert-local.key.pem").path();
if tokio::fs::metadata(&key_path).await.is_err() {
@@ -305,6 +305,7 @@ pub async fn write_lan_services(hidden_services: &ServicesMap) -> Result<(), Err
}
let fullchain_path = base_path.join("cert-local.fullchain.crt.pem");
if !fullchain_path.exists().await {
log::info!("Writing fullchain to: {}", fullchain_path.path().display());
let mut fullchain_file = fullchain_path.write(None).await?;
tokio::io::copy(
&mut tokio::fs::File::open(&cert_path).await?,
@@ -339,6 +340,7 @@ pub async fn write_lan_services(hidden_services: &ServicesMap) -> Result<(), Err
)
.await?;
fullchain_file.commit().await?;
log::info!("{} written successfully", fullchain_path.path().display());
}
f.write_all(
format!(