add composite FileKind

This commit is contained in:
Mikaël Cluseau
2026-04-27 21:27:16 +02:00
parent 5414b1d529
commit 71f4faa8cb
2 changed files with 29 additions and 3 deletions
+19 -1
View File
@@ -14,7 +14,7 @@ pub async fn files(files: &[crate::File], root: &str, dry_run: bool) -> Result<(
fs::create_dir_all(parent).await?;
}
use crate::FileKind as K;
use crate::{FileKind as K, FilePart as P};
match &file.kind {
K::Content(content) => {
if dry_run {
@@ -39,6 +39,24 @@ pub async fn files(files: &[crate::File], root: &str, dry_run: bool) -> Result<(
fs::write(path, content).await?
}
}
K::Parts(parts) => {
let mut assembly = Vec::new();
for part in parts {
match part {
P::Content(content) => assembly.extend(content.as_bytes()),
P::Content64(content) => assembly.extend(base64_decode(content)?),
}
}
if dry_run {
info!(
"would create {} ({} bytes from parts)",
file.path,
assembly.len()
);
} else {
fs::write(path, assembly).await?
}
}
K::Dir(true) => {
if dry_run {
info!("would create {} (directory)", file.path);