Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
fffae453ee
commit
0a258829f7
@ -1,7 +1,9 @@
|
|||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
pub struct Archive {}
|
pub struct Archive {}
|
||||||
|
|
||||||
use std::io::Cursor;
|
use std::{io::Cursor, path::Path};
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
|
|
||||||
use super::file_reader::Files;
|
use super::file_reader::Files;
|
||||||
|
|
||||||
@ -10,7 +12,7 @@ impl Archive {
|
|||||||
Self {}
|
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());
|
tracing::trace!("archiving files: {}", files.len());
|
||||||
|
|
||||||
let buffer = Vec::new();
|
let buffer = Vec::new();
|
||||||
@ -27,7 +29,12 @@ impl Archive {
|
|||||||
tar_builder.append_file(&rel, &mut fd)?;
|
tar_builder.append_file(&rel, &mut fd)?;
|
||||||
} else {
|
} else {
|
||||||
tracing::trace!("archiving file: {}", abs_file_path.display());
|
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,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,10 @@ impl FluxLocalClusterManager {
|
|||||||
&self,
|
&self,
|
||||||
include: impl Into<PathBuf>,
|
include: impl Into<PathBuf>,
|
||||||
) -> anyhow::Result<UploadArtifactID> {
|
) -> anyhow::Result<UploadArtifactID> {
|
||||||
let files = self.file_reader.read_files(include.into()).await?;
|
let include = include.into();
|
||||||
let archive = self.archive.create_archive(files).await?;
|
|
||||||
|
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?;
|
let upload_id = self.flux_uploader.upload_archive(archive).await?;
|
||||||
|
|
||||||
Ok(upload_id)
|
Ok(upload_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user