messages
This commit is contained in:
@@ -4,7 +4,7 @@ use clap::Parser;
|
||||
use std::fs::read;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::{fs, io};
|
||||
use std::{fs, io, time};
|
||||
use utils::Zsdiff;
|
||||
|
||||
async fn create_tmp_dir(dir_name: String) -> Result<String, io::Error> {
|
||||
@@ -33,6 +33,7 @@ async fn check_hash(filename: String) -> Result<(), io::Error> {
|
||||
if !String::from_utf8(hash_file).unwrap().eq(&hash) {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "Hash mismatch"));
|
||||
}
|
||||
println!("Zsdiff hash: {}", hash);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -41,6 +42,7 @@ async fn zspatch(filename: String, dest_dir: String) -> Result<(), io::Error> {
|
||||
let parts = utils::decompress_parts(read(filename)?).await?;
|
||||
let diff = Zsdiff::from_vec(parts).await?;
|
||||
let tmp_dir_name = extract_files(&diff, filename).await?;
|
||||
let now = time::Instant::now();
|
||||
for name in diff.content.keys().collect::<Vec<&String>>() {
|
||||
let from_path = Path::new(&tmp_dir_name).join(name);
|
||||
let to_path = Path::new(&dest_dir).join(name);
|
||||
@@ -62,6 +64,8 @@ async fn zspatch(filename: String, dest_dir: String) -> Result<(), io::Error> {
|
||||
}
|
||||
}
|
||||
fs::remove_dir_all(tmp_dir_name).ok();
|
||||
println!("Patching done!");
|
||||
println!("Elapsed time: {:.2?}", now.elapsed());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -78,7 +82,6 @@ struct Args {
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
let args = Args::parse();
|
||||
println!("{}", args.hash_check);
|
||||
if args.hash_check {
|
||||
check_hash(args.filename.clone()).await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user