feat: without prefix
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-05-25 23:35:53 +02:00
parent fffae453ee
commit 0a258829f7
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
2 changed files with 15 additions and 6 deletions

View File

@ -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,
)?;
}
}

View File

@ -40,8 +40,10 @@ impl FluxLocalClusterManager {
&self,
include: impl Into<PathBuf>,
) -> anyhow::Result<UploadArtifactID> {
let files = self.file_reader.read_files(include.into()).await?;
let archive = self.archive.create_archive(files).await?;
let include = include.into();
let files = self.file_reader.read_files(include.clone()).await?;
let archive = self.archive.create_archive(&include, files).await?;
let upload_id = self.flux_uploader.upload_archive(archive).await?;
Ok(upload_id)