style: code style
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
use rust_util::XResult;
|
||||
use argparse::{
|
||||
ArgumentParser,
|
||||
Store,
|
||||
StoreTrue,
|
||||
};
|
||||
use argparse::{ ArgumentParser, Store, StoreTrue };
|
||||
|
||||
const EMPTY: &str = "";
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use std::fs::File;
|
||||
use sha1::Sha1;
|
||||
use hmac::{ Hmac, Mac, };
|
||||
use hmac::{ Hmac, Mac };
|
||||
use reqwest::Response;
|
||||
use rust_util::{
|
||||
iff,
|
||||
XResult,
|
||||
new_box_ioerror,
|
||||
util_time::get_current_secs,
|
||||
|
||||
@@ -3,14 +3,9 @@ use crate::openpgp::armor;
|
||||
use std::{
|
||||
fs::File,
|
||||
path::Path,
|
||||
io::{
|
||||
ErrorKind,
|
||||
Read,
|
||||
Write,
|
||||
BufWriter,
|
||||
},
|
||||
io::{ ErrorKind, Read, Write, BufWriter },
|
||||
};
|
||||
use rust_util::{ XResult, new_box_error, };
|
||||
use rust_util::{ XResult, new_box_error };
|
||||
use openpgp::{
|
||||
Cert,
|
||||
parse::Parse,
|
||||
@@ -22,7 +17,7 @@ use openpgp::{
|
||||
},
|
||||
policy::StandardPolicy as P,
|
||||
};
|
||||
use indicatif::{ ProgressBar, ProgressStyle, };
|
||||
use indicatif::{ ProgressBar, ProgressStyle };
|
||||
|
||||
const BUFF_SIZE: usize = 512 * 1024;
|
||||
const PB_PROGRESS: &str = "#-";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
fs::File,
|
||||
@@ -7,7 +6,7 @@ use std::{
|
||||
};
|
||||
use zip::{
|
||||
CompressionMethod,
|
||||
write::{ ZipWriter, FileOptions, },
|
||||
write::{ ZipWriter, FileOptions },
|
||||
};
|
||||
use flate2:: {
|
||||
Compression,
|
||||
@@ -16,7 +15,6 @@ use flate2:: {
|
||||
use rust_util::{
|
||||
XResult,
|
||||
new_box_ioerror,
|
||||
util_msg::print_warn,
|
||||
util_io::*,
|
||||
util_file::*,
|
||||
};
|
||||
@@ -63,19 +61,19 @@ pub fn zip_file(target: &str, zip_file: &str) -> XResult<()> {
|
||||
} else {
|
||||
let mut_zip = RefCell::new(zip);
|
||||
walk_dir(&target_path, &|p, e| {
|
||||
print_warn(&format!("Compress {} failed: {}", &p.display(), &e));
|
||||
warning!("Compress {} failed: {}", &p.display(), &e);
|
||||
}, &|f| {
|
||||
let options = FileOptions::default().compression_method(CompressionMethod::Stored);
|
||||
let mut m_zip = mut_zip.borrow_mut();
|
||||
let file_name = get_file_name(&f); // TODO file name! add path
|
||||
match m_zip.start_file(&file_name, options) {
|
||||
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)) {
|
||||
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 })?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user