diff --git a/src/hpk.rs b/src/hpk.rs index 231074d..87eda3c 100644 --- a/src/hpk.rs +++ b/src/hpk.rs @@ -3,7 +3,7 @@ use { cli::cli, hpk::{Dependency, Specs, Version}, ron::ser::{to_writer_pretty, PrettyConfig}, - std::{error::Error, env, fs::File, io::BufWriter, path::PathBuf}, + std::{env, error::Error, fs::File, io::BufWriter, path::PathBuf}, }; fn main() -> Result<(), Box> { diff --git a/src/package/mod.rs b/src/package/mod.rs index 9d3cc33..0f8cef7 100644 --- a/src/package/mod.rs +++ b/src/package/mod.rs @@ -1,5 +1,6 @@ use crate::Item; -use std::{path::PathBuf, fs}; +use std::{fs, path::PathBuf}; +use tar::Owner; use zstd::Encoder; mod dependency; @@ -101,10 +102,12 @@ impl Package { writer.write_all(s.as_bytes())?; writer.flush()?; println!("{} written", outfile.display()); - let dir = env::current_dir()?; - env::set_current_dir(outdir)?; - let node = Node::read_file_to_tar("package.ron")?; - env::set_current_dir(dir)?; + let node = Node::read_data_to_tar( + s.as_bytes(), + "package.ron", + &outfile.metadata()?, + Some(Owner::default()), + )?; Ok(node) } @@ -124,9 +127,7 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box>() .par_iter() .filter(|x| x.is_ok()) - .filter_map(|x| { - Item::try_create(x.as_ref().unwrap().path().to_path_buf().as_path()).ok() - }) + .filter_map(|x| Item::try_create(x.as_ref().unwrap().path().to_path_buf().as_path()).ok()) .collect::>(); let mut plist = Plist::default(); let mut archive = vec![]; @@ -147,10 +148,8 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box