mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Check value in set_progress
This commit is contained in:
@@ -74,6 +74,13 @@ impl FileTransferActivity {
|
|||||||
///
|
///
|
||||||
/// Calculate progress percentage based on current progress
|
/// Calculate progress percentage based on current progress
|
||||||
pub(super) fn set_progress(&mut self, it: usize, sz: usize) {
|
pub(super) fn set_progress(&mut self, it: usize, sz: usize) {
|
||||||
self.transfer_progress = ((it as f64) * 100.0) / (sz as f64);
|
let mut prog: f64 = ((it as f64) * 100.0) / (sz as f64);
|
||||||
|
// Check value
|
||||||
|
if prog > 100.0 {
|
||||||
|
prog = 100.0;
|
||||||
|
} else if prog < 0.0 {
|
||||||
|
prog = 0.0;
|
||||||
|
}
|
||||||
|
self.transfer_progress = prog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user