add composite FileKind
This commit is contained in:
+19
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user