patch hash check
This commit is contained in:
@@ -2,6 +2,7 @@ mod utils;
|
||||
|
||||
use clap::Parser;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Write;
|
||||
use std::{fs, io};
|
||||
use utils::{Metadata, Zsdiff, get_hash};
|
||||
use walkdir::WalkDir;
|
||||
@@ -21,7 +22,7 @@ async fn walk_dir(dir: String) -> HashMap<String, FileInfo> {
|
||||
continue;
|
||||
}
|
||||
let content = fs::read(path).unwrap();
|
||||
let hash = get_hash(&content).await;
|
||||
let hash = get_hash(content).await;
|
||||
let path_str = path.display().to_string();
|
||||
let file_info = FileInfo {
|
||||
relative_path: path_str[dir.len() + 1..].to_string(),
|
||||
@@ -76,12 +77,10 @@ pub async fn zsdiff(
|
||||
let new_hashes = walk_dir(new).await;
|
||||
let compare_hashes = compare_hashes(old_hashes, new_hashes).await;
|
||||
let parts = compare_hashes.to_vec().await;
|
||||
let file = fs::File::create(output_filename)?;
|
||||
utils::compress_parts(parts, &file, level).await;
|
||||
// let mut buf = Vec::new();
|
||||
// file.read(&mut buf)?;
|
||||
// let output_hash = get_hash(&buf).await;
|
||||
// println!("{}", output_hash);
|
||||
utils::compress_parts(parts, &fs::File::create(output_filename)?, level).await;
|
||||
let output_hash = get_hash(fs::read(output_filename)?).await;
|
||||
fs::File::create(format!("{}.md5", output_filename))?.write_all(output_hash.as_bytes())?;
|
||||
println!("Zsdiff hash: {}", output_hash);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -100,6 +99,5 @@ struct Args {
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
let args = Args::parse();
|
||||
zsdiff(args.filename, args.old, args.new, args.compress_level).await?;
|
||||
Ok(())
|
||||
zsdiff(args.filename, args.old, args.new, args.compress_level).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user