summaryrefslogtreecommitdiffstats
path: root/src/app/data_harvester/network.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/data_harvester/network.rs')
-rw-r--r--src/app/data_harvester/network.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/app/data_harvester/network.rs b/src/app/data_harvester/network.rs
index 2c2dba7d..c425ccd6 100644
--- a/src/app/data_harvester/network.rs
+++ b/src/app/data_harvester/network.rs
@@ -45,8 +45,14 @@ pub async fn get_network_data(
let elapsed_time = curr_time.duration_since(prev_net_access_time).as_secs_f64();
- let rx = ((total_rx - *prev_net_rx) as f64 / elapsed_time) as u64;
- let tx = ((total_tx - *prev_net_tx) as f64 / elapsed_time) as u64;
+ let (rx, tx) = if elapsed_time == 0.0 {
+ (0, 0)
+ } else {
+ (
+ ((total_rx - *prev_net_rx) as f64 / elapsed_time) as u64,
+ ((total_tx - *prev_net_tx) as f64 / elapsed_time) as u64,
+ )
+ };
*prev_net_rx = total_rx;
*prev_net_tx = total_tx;