feat: optimize code
This commit is contained in:
@@ -210,7 +210,7 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
|
||||
Ok(meta.file_length)
|
||||
}
|
||||
|
||||
fn decrypt_file(file_in: &mut File, file_len: u64, file_out: &mut impl Write,
|
||||
fn decrypt_file(file_in: &mut impl Read, file_len: u64, file_out: &mut impl Write,
|
||||
cryptor: Cryptor, key_nonce: &KeyNonce, compress: bool) -> XResult<u64> {
|
||||
let mut total_len = 0_u64;
|
||||
let mut buffer = [0u8; 1024 * 8];
|
||||
|
||||
@@ -96,8 +96,7 @@ pub fn direct_decrypt(cmd_direct_decrypt: CmdDirectDecrypt) -> XResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
fn decrypt_file(file_in: &mut File, file_len: u64, file_out: &mut impl Write,
|
||||
fn decrypt_file(file_in: &mut impl Read, file_len: u64, file_out: &mut impl Write,
|
||||
cryptor: Cryptor, key_nonce: &KeyNonce) -> XResult<u64> {
|
||||
let mut total_len = 0_u64;
|
||||
let mut buffer = [0u8; 1024 * 8];
|
||||
|
||||
@@ -184,7 +184,7 @@ pub fn encrypt_single_file_out(path: &PathBuf, path_out: &str, envelops: &[&Tiny
|
||||
Ok(file_metadata.len())
|
||||
}
|
||||
|
||||
fn encrypt_file(file_in: &mut File, file_len: u64, file_out: &mut impl Write, cryptor: Cryptor,
|
||||
fn encrypt_file(file_in: &mut impl Read, file_len: u64, file_out: &mut impl Write, cryptor: Cryptor,
|
||||
key_nonce: &KeyNonce, compress_level: &Option<u32>) -> XResult<u64> {
|
||||
let compress = compress_level.is_some();
|
||||
let mut total_len = 0_u64;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::fs::Metadata;
|
||||
|
||||
use flate2::Compression;
|
||||
use rust_util::{opt_result, util_time, XResult};
|
||||
use rust_util::util_time::get_millis;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
Reference in New Issue
Block a user