v0.3
This commit is contained in:
5
Makefile
5
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
|
||||
cargo build --release --target x86_64-pc-windows-gnu --package zsdiff_all --bin zsdiff
|
||||
|
||||
clean:
|
||||
rm -Rf target/
|
||||
@@ -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)
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user