mirror of
https://github.com/Prominence/rshred.git
synced 2026-01-09 02:06:46 +03:00
Small refactoring.
This commit is contained in:
parent
b694eb3724
commit
7aebbe6f9d
10
src/lib.rs
10
src/lib.rs
@ -85,7 +85,7 @@ impl<'a> Shredder<'a> {
|
|||||||
&file,
|
&file,
|
||||||
file_length,
|
file_length,
|
||||||
absolute_path,
|
absolute_path,
|
||||||
&configuration.rewrite_iterations,
|
configuration.rewrite_iterations,
|
||||||
);
|
);
|
||||||
|
|
||||||
if !configuration.keep_files {
|
if !configuration.keep_files {
|
||||||
@ -109,7 +109,7 @@ impl<'a> Shredder<'a> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shred_file(file: &File, file_length: u64, absolute_path: &str, iterations: &u8) {
|
fn shred_file(file: &File, file_length: u64, absolute_path: &str, iterations: u8) {
|
||||||
let mut buffer = BufWriter::new(file);
|
let mut buffer = BufWriter::new(file);
|
||||||
|
|
||||||
let pb = ProgressBar::new(file_length);
|
let pb = ProgressBar::new(file_length);
|
||||||
@ -118,8 +118,8 @@ impl<'a> Shredder<'a> {
|
|||||||
.template("{prefix} {spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} {bytes_per_sec} ({eta})")
|
.template("{prefix} {spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} {bytes_per_sec} ({eta})")
|
||||||
.progress_chars("#>-"));
|
.progress_chars("#>-"));
|
||||||
|
|
||||||
for i in 0..*iterations {
|
for i in 0..iterations {
|
||||||
pb.set_prefix(&format!("Iteration {}/{}", i + 1, *iterations));
|
pb.set_prefix(&format!("Iteration {}/{}", i + 1, iterations));
|
||||||
let mut bytes_processed = 0;
|
let mut bytes_processed = 0;
|
||||||
while bytes_processed < file_length {
|
while bytes_processed < file_length {
|
||||||
let bytes_to_write = if file_length - bytes_processed > BATCH_SIZE as u64 {
|
let bytes_to_write = if file_length - bytes_processed > BATCH_SIZE as u64 {
|
||||||
@ -279,7 +279,7 @@ impl Ord for Verbosity {
|
|||||||
|
|
||||||
impl PartialOrd for Verbosity {
|
impl PartialOrd for Verbosity {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
Some(self.discriminant().cmp(&other.discriminant()))
|
Some(self.cmp(other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user