Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Archive {}
|
||||
|
||||
use std::io::Cursor;
|
||||
use std::{io::Cursor, path::Path};
|
||||
|
||||
use anyhow::Context;
|
||||
|
||||
use super::file_reader::Files;
|
||||
|
||||
@@ -10,7 +12,7 @@ impl Archive {
|
||||
Self {}
|
||||
}
|
||||
|
||||
pub async fn create_archive(&self, files: Files) -> anyhow::Result<ArchiveFile> {
|
||||
pub async fn create_archive(&self, prefix: &Path, files: Files) -> anyhow::Result<ArchiveFile> {
|
||||
tracing::trace!("archiving files: {}", files.len());
|
||||
|
||||
let buffer = Vec::new();
|
||||
@@ -27,7 +29,12 @@ impl Archive {
|
||||
tar_builder.append_file(&rel, &mut fd)?;
|
||||
} else {
|
||||
tracing::trace!("archiving file: {}", abs_file_path.display());
|
||||
tar_builder.append_file(&abs_file_path, &mut fd)?;
|
||||
tar_builder.append_file(
|
||||
abs_file_path
|
||||
.strip_prefix(prefix)
|
||||
.context("failed to strip prefix from path")?,
|
||||
&mut fd,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user