style: code style

This commit is contained in:
2020-08-02 23:06:21 +08:00
parent 5ecf3335b4
commit 9bd386a3c7
4 changed files with 10 additions and 22 deletions

View File

@@ -1,9 +1,5 @@
use rust_util::XResult; use rust_util::XResult;
use argparse::{ use argparse::{ ArgumentParser, Store, StoreTrue };
ArgumentParser,
Store,
StoreTrue,
};
const EMPTY: &str = ""; const EMPTY: &str = "";

View File

@@ -1,9 +1,8 @@
use std::fs::File; use std::fs::File;
use sha1::Sha1; use sha1::Sha1;
use hmac::{ Hmac, Mac, }; use hmac::{ Hmac, Mac };
use reqwest::Response; use reqwest::Response;
use rust_util::{ use rust_util::{
iff,
XResult, XResult,
new_box_ioerror, new_box_ioerror,
util_time::get_current_secs, util_time::get_current_secs,

View File

@@ -3,14 +3,9 @@ use crate::openpgp::armor;
use std::{ use std::{
fs::File, fs::File,
path::Path, path::Path,
io::{ io::{ ErrorKind, Read, Write, BufWriter },
ErrorKind,
Read,
Write,
BufWriter,
},
}; };
use rust_util::{ XResult, new_box_error, }; use rust_util::{ XResult, new_box_error };
use openpgp::{ use openpgp::{
Cert, Cert,
parse::Parse, parse::Parse,
@@ -22,7 +17,7 @@ use openpgp::{
}, },
policy::StandardPolicy as P, policy::StandardPolicy as P,
}; };
use indicatif::{ ProgressBar, ProgressStyle, }; use indicatif::{ ProgressBar, ProgressStyle };
const BUFF_SIZE: usize = 512 * 1024; const BUFF_SIZE: usize = 512 * 1024;
const PB_PROGRESS: &str = "#-"; const PB_PROGRESS: &str = "#-";

View File

@@ -1,4 +1,3 @@
use std::{ use std::{
cell::RefCell, cell::RefCell,
fs::File, fs::File,
@@ -7,7 +6,7 @@ use std::{
}; };
use zip::{ use zip::{
CompressionMethod, CompressionMethod,
write::{ ZipWriter, FileOptions, }, write::{ ZipWriter, FileOptions },
}; };
use flate2:: { use flate2:: {
Compression, Compression,
@@ -16,7 +15,6 @@ use flate2:: {
use rust_util::{ use rust_util::{
XResult, XResult,
new_box_ioerror, new_box_ioerror,
util_msg::print_warn,
util_io::*, util_io::*,
util_file::*, util_file::*,
}; };
@@ -63,19 +61,19 @@ pub fn zip_file(target: &str, zip_file: &str) -> XResult<()> {
} else { } else {
let mut_zip = RefCell::new(zip); let mut_zip = RefCell::new(zip);
walk_dir(&target_path, &|p, e| { walk_dir(&target_path, &|p, e| {
print_warn(&format!("Compress {} failed: {}", &p.display(), &e)); warning!("Compress {} failed: {}", &p.display(), &e);
}, &|f| { }, &|f| {
let options = FileOptions::default().compression_method(CompressionMethod::Stored); let options = FileOptions::default().compression_method(CompressionMethod::Stored);
let mut m_zip = mut_zip.borrow_mut(); let mut m_zip = mut_zip.borrow_mut();
let file_name = get_file_name(&f); // TODO file name! add path let file_name = get_file_name(&f); // TODO file name! add path
match m_zip.start_file(&file_name, options) { match m_zip.start_file(&file_name, options) {
Ok(_) => match File::open(f) { Ok(_) => match File::open(f) {
Err(e) => print_warn(&format!("Compress {} failed: {}", &f.display(), e)), Err(e) => warning!("Compress {} failed: {}", &f.display(), e),
Ok(mut ff) => if let Err(e) = copy_io_with_head(&mut ff, &mut *m_zip, -1, &format!("Compressing {}", &file_name)) { Ok(mut ff) => if let Err(e) = copy_io_with_head(&mut ff, &mut *m_zip, -1, &format!("Compressing {}", &file_name)) {
print_warn(&format!("Compress {} failed: {}", &f.display(), e)) warning!("Compress {} failed: {}", &f.display(), e)
} }
}, },
Err(e) => print_warn(&format!("Compress {} failed: {}", &f.display(), e)), Err(e) => warning!("Compress {} failed: {}", &f.display(), e),
}; };
}, &|_| { true })?; }, &|_| { true })?;