diff --git a/Makefile b/Makefile index c8c87d6..f3dac9f 100644 --- a/Makefile +++ b/Makefile @@ -6,4 +6,7 @@ build-linux: build-win: cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zspatch - cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zsdiff \ No newline at end of file + cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zsdiff + +clean: + rm -Rf target/ \ No newline at end of file diff --git a/src/utils.rs b/src/utils.rs index 452f4d3..3ca3644 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,4 +1,3 @@ -use crate::utils; use md5; use rsa::pkcs1::{DecodeRsaPrivateKey, EncodeRsaPrivateKey, EncodeRsaPublicKey}; use rsa::pkcs8::LineEnding; @@ -179,7 +178,6 @@ impl Compressor { pub struct Encrypter { private_key: RsaPrivateKey, public_key: RsaPublicKey, - key_size: usize, } impl Encrypter { pub fn new_pair() -> Self { @@ -190,14 +188,12 @@ impl Encrypter { Self { private_key, public_key, - key_size: bits, } } pub fn from_private_key(private_key: RsaPrivateKey) -> Self { let public_key = RsaPublicKey::from(&private_key); Self { - key_size: public_key.size(), public_key, private_key, } @@ -205,7 +201,6 @@ impl Encrypter { pub fn new(private_key: RsaPrivateKey, public_key: RsaPublicKey) -> Self { Self { - key_size: public_key.size(), private_key, public_key, } @@ -220,7 +215,7 @@ impl Encrypter { let segment = self .public_key .encrypt(&mut rng, Pkcs1v15Encrypt, seg) - .unwrap(); + .expect("Can't encrypt segment"); out.extend(segment) } Ok(out) diff --git a/src/zsdiff.rs b/src/zsdiff.rs index 5277eec..fb4d8f7 100644 --- a/src/zsdiff.rs +++ b/src/zsdiff.rs @@ -2,7 +2,6 @@ mod utils; use clap::Parser; use std::collections::HashMap; -use std::fmt::format; use std::io::Write; use std::{fs, io, time}; use utils::{Metadata, Zsdiff, get_hash}; diff --git a/src/zspatch.rs b/src/zspatch.rs index 700d1e6..add3ffc 100644 --- a/src/zspatch.rs +++ b/src/zspatch.rs @@ -1,7 +1,7 @@ mod utils; use crate::utils::Metadata; -use clap::{Arg, ArgAction, ArgMatches, Command, Parser}; +use clap::{Arg, ArgAction, Command, Parser}; use std::path::{Path, PathBuf}; use std::{io, time}; use tokio::fs; @@ -177,18 +177,6 @@ async fn zspatch(filename: String, dest_dir: String) -> Result<(), io::Error> { Ok(()) } -#[derive(Parser)] -struct Args { - #[arg(short, long)] - filename: String, - #[arg(short, long)] - dest_dir: String, - #[arg(short, long)] - metadata: bool, - #[arg(short, long)] - check_hash: bool, -} - #[tokio::main] async fn main() -> io::Result<()> { let m = Command::new("ZsPatch") @@ -216,12 +204,14 @@ async fn main() -> io::Result<()> { .arg( Arg::new("filename") .short('f') + .long("filename") .required(true) .action(ArgAction::Set), ) .arg( Arg::new("dest") .short('d') + .long("dest") .required(true) .action(ArgAction::Set), ) @@ -256,20 +246,4 @@ async fn main() -> io::Result<()> { _ => unreachable!("Subcommand is required"), } Ok(()) - - // let args = Args::parse(); - // - // let filename = args.filename.clone(); - // let dest_dir = args.dest_dir.clone(); - // - // if args.check_hash { - // check_hash(args.filename.clone()).await.ok(); - // } - // if args.metadata { - // let diff = load_file(filename).await?; - // let metadata = diff.metadata; - // println!(">>> Compress level: {}", metadata.compress_level); - // return Ok(()); - // } - // zspatch(filename, dest_dir).await }