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 656bacf8 authored by Stefan Schindler's avatar Stefan Schindler
Browse files

Correctly report the speed and the time it took

parent b7db3d92
......@@ -354,9 +354,13 @@ fn update_jobs(disks: &Vec<Arc<DiskInformation>>, pool: &threadpool::ThreadPool)
println!("{}{}", Blue.paint("Wiping "), BOLD.paint(&*disk.name));
match whipe_disk(&disk) {
Ok(_) => {
Ok(duration) => {
*disk.state.lock().unwrap() = Wiped;
println!("{}{}", Green.paint("Wiped "), BOLD.paint(&*disk.name));
println!("{}{} in {}",
Green.dimmed().paint("Wiped "),
BOLD.paint(&*disk.name),
duration
);
},
Err(e) => {
*disk.state.lock().unwrap() = WipeFailed;
......@@ -374,7 +378,7 @@ fn update_jobs(disks: &Vec<Arc<DiskInformation>>, pool: &threadpool::ThreadPool)
}
}
fn whipe_disk(disk: &Arc<DiskInformation>) -> std::io::Result<()> {
fn whipe_disk(disk: &Arc<DiskInformation>) -> std::io::Result<std::time::Duration> {
let mut rng = rand::thread_rng();
*disk.state.lock().unwrap() = Wiping{ progress: Byte(0), per_second: Byte(0) };
......@@ -387,22 +391,22 @@ fn whipe_disk(disk: &Arc<DiskInformation>) -> std::io::Result<()> {
let mut i: u64 = 0;
let now = Instant::now();
let mut last_position = Byte(0);
while position < disk.size {
rng.fill_bytes(&mut buf);
disk_file.write_all(&buf)?;
rng.fill_bytes(&mut *buf);
disk_file.write_all(&*buf)?;
position += Byte(WRITE_BUFFER_SIZE as u64);
i += 1;
if i % 1024 == 0 {
let delta = position.clone() - last_position;
*disk.state.lock().unwrap() = Wiping{ progress: position.clone(), per_second: delta.byte_per_second(now.elapsed()) };
last_position = position.clone();
if i % 1024*1024 == 0 {
*disk.state.lock().unwrap() = Wiping{
progress: position.clone(),
per_second: position.byte_per_second(now.elapsed()),
};
}
}
Ok( () )
Ok( now.elapsed() )
}
......
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