To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit ce8c7bd5 authored by Stefan Schindler's avatar Stefan Schindler
Browse files

Finish rename

parent fd05eea0
[root]
name = "whipe_buddy"
name = "wipe_buddy"
version = "0.1.0"
dependencies = [
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
......
......@@ -347,15 +347,17 @@ fn update_jobs(disks: &Vec<Arc<DiskInformation>>, pool: &threadpool::ThreadPool)
let disk = disk.clone();
pool.execute(move || {
println!("{}{}", Blue.paint("Wiping "), BOLD.paint(&*disk.name));
match whipe_disk(&disk) {
Ok(_) => {
*disk.state.lock().unwrap() = Whiped;
println!("{}{}", Green.paint("Whiped "), BOLD.paint(&*disk.name));
*disk.state.lock().unwrap() = Wiped;
println!("{}{}", Green.paint("Wiped "), BOLD.paint(&*disk.name));
},
Err(e) => {
*disk.state.lock().unwrap() = WhipeFailed;
*disk.state.lock().unwrap() = WipeFailed;
println!("{}{}{}",
Red.paint("Whipe of "),
Red.paint("Wipe of "),
BOLD.paint(&*disk.name),
Red.paint(format!(" failed: {:?}", e))
);
......@@ -371,7 +373,7 @@ fn update_jobs(disks: &Vec<Arc<DiskInformation>>, pool: &threadpool::ThreadPool)
fn whipe_disk(disk: &Arc<DiskInformation>) -> std::io::Result<()> {
let mut rng = rand::thread_rng();
*disk.state.lock().unwrap() = Whiping{ progress: Byte(0), per_second: Byte(0) };
*disk.state.lock().unwrap() = Wiping{ progress: Byte(0), per_second: Byte(0) };
let mut buf = [0; WRITE_BUFFER_SIZE];
let mut position = Byte(0);
......@@ -391,7 +393,7 @@ fn whipe_disk(disk: &Arc<DiskInformation>) -> std::io::Result<()> {
i += 1;
if i % 1024 == 0 {
let delta = position.clone() - last_position;
*disk.state.lock().unwrap() = Whiping{ progress: position.clone(), per_second: delta.byte_per_second(now.elapsed()) };
*disk.state.lock().unwrap() = Wiping{ progress: position.clone(), per_second: delta.byte_per_second(now.elapsed()) };
last_position = position.clone();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment