Create tar node for package.ron
directly from in memory data
This commit is contained in:
parent
b9116951d5
commit
26af277e28
@ -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<dyn Error>> {
|
||||
|
@ -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<dyn Er
|
||||
.collect::<Vec<_>>()
|
||||
.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::<Vec<_>>();
|
||||
let mut plist = Plist::default();
|
||||
let mut archive = vec![];
|
||||
@ -147,10 +148,8 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box<dyn Er
|
||||
let mut package: Package = specs.into();
|
||||
package.plist = plist;
|
||||
package.size = totalsize;
|
||||
println!("creating package.ron");
|
||||
let node = package.save_ron_and_create_tar_node(&outdir)?.to_vec()?;
|
||||
archive.extend(node);
|
||||
//archive.write_all(&[0; 9216])?;
|
||||
let name = package.fullname();
|
||||
let mut path = PathBuf::from(&name);
|
||||
path.set_extension("tar.zst");
|
||||
|
Loading…
Reference in New Issue
Block a user