Sites are now explicitely defined
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful

This fixes the issue where deploying the default site would delete all
other sites, because they're subdirs of the default dir.
This commit is contained in:
Jef Roosens 2022-04-05 10:45:42 +02:00
parent 143f892c52
commit 6505e02dd4
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 46 additions and 17 deletions

View file

@ -11,7 +11,7 @@ use serde::Deserialize;
use tar::Archive;
use tokio_util::io::StreamReader;
use crate::DEFAULT_STATIC_DIR_NAME;
use crate::{DEFAULT_STATIC_SITE, STATIC_DIR_NAME};
#[derive(Deserialize)]
pub struct StaticDirParams
@ -34,11 +34,10 @@ pub async fn post_deploy(
let mut file = tokio::fs::File::create(&file_path).await.unwrap();
tokio::io::copy(&mut read, &mut file).await;
let mut static_path = Path::new(&data_dir).join(DEFAULT_STATIC_DIR_NAME);
if params.dir.is_some() {
static_path = static_path.join(params.dir.unwrap());
}
// If no dir is provided, we use the default one. Otherwise, use the provided one.
let static_path = Path::new(&data_dir)
.join(STATIC_DIR_NAME)
.join(params.dir.unwrap_or(DEFAULT_STATIC_SITE.to_string()));
// Make sure the static directory exists
tokio::fs::create_dir_all(&static_path).await;