mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-27 17:20:06 +08:00
update rust_util
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -615,7 +615,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -629,7 +629,7 @@ dependencies = [
|
||||
"cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1095,7 +1095,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rust_util"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/jht5945/rust_util#5cae3115806ef87926cffdc814c5e5575070cc44"
|
||||
source = "git+https://github.com/jht5945/rust_util#29e719477fd9e88a6aa4938ba678e664eee267d7"
|
||||
dependencies = [
|
||||
"term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1636,7 +1636,7 @@ dependencies = [
|
||||
"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f"
|
||||
"checksum mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3e27ca21f40a310bd06d9031785f4801710d566c184a6e15bad4f1d9b65f9425"
|
||||
"checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599"
|
||||
"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516"
|
||||
"checksum miniz_oxide 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe2959c5a0747a8d7a56b4444c252ffd2dda5d452cfd147cdfdda73b1c3ece5b"
|
||||
"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4"
|
||||
"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23"
|
||||
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
io::{Read, ErrorKind},
|
||||
path::Path,
|
||||
process::Command,
|
||||
time::{SystemTime, Duration},
|
||||
time::SystemTime,
|
||||
};
|
||||
|
||||
use rust_util::{
|
||||
@@ -15,8 +15,6 @@ use rust_util::{
|
||||
},
|
||||
XResult,
|
||||
util_io::*,
|
||||
util_msg::*,
|
||||
util_size::*,
|
||||
};
|
||||
|
||||
use crypto::{
|
||||
@@ -58,27 +56,6 @@ pub fn calc_sha256(d: &[u8]) -> String {
|
||||
sha256.result_str()
|
||||
}
|
||||
|
||||
// TODO move to rust_util
|
||||
fn print_status_last_line(head: &str, total: i64, written: i64, cost: Duration) {
|
||||
let mut download_speed = "-".to_string();
|
||||
let cost_as_secs = cost.as_secs();
|
||||
if cost_as_secs > 0 {
|
||||
download_speed = format!("{}/s", get_display_size((written / (cost_as_secs as i64)) as i64));
|
||||
}
|
||||
if total > 0 {
|
||||
print_lastline(&format!("{}, Total: {}, Finished: {}, Speed: {}",
|
||||
head,
|
||||
get_display_size(total),
|
||||
get_display_size(written),
|
||||
download_speed));
|
||||
} else {
|
||||
print_lastline(&format!("{}, Finished: {}, Speed: {}",
|
||||
head,
|
||||
get_display_size(written),
|
||||
download_speed));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn calc_file_sha256(file_name: &str) -> XResult<String> {
|
||||
let mut sha256 = Sha256::new();
|
||||
let mut buf: [u8; DEFAULT_BUF_SIZE] = [0u8; DEFAULT_BUF_SIZE];
|
||||
|
||||
Reference in New Issue
Block a user