From ed9721f2eaa5a13bd65b16544c24254fd2e4cf88 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 7 Mar 2024 14:31:27 +0100 Subject: [PATCH] sync job: avoid printing NaN if no data was pulled Previously, if there was no data to pull one could get: > Summary: sync job pulled 0 B in 0 chunks (average rate: NaN B/s) Now one gets the following log entry in that case: > Summary: sync job found no new data to pull Signed-off-by: Thomas Lamprecht --- src/api2/pull.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/api2/pull.rs b/src/api2/pull.rs index b72e5cef..29abc1c2 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -146,15 +146,20 @@ pub fn do_sync_job( ); let pull_stats = pull_store(&worker, pull_params).await?; - task_log!( - worker, - "Summary: sync job pulled {} in {} chunks (average rate: {}/s)", - HumanByte::from(pull_stats.bytes), - pull_stats.chunk_count, - HumanByte::new_binary( - pull_stats.bytes as f64 / pull_stats.elapsed.as_secs_f64() - ), - ); + + if pull_stats.bytes != 0 { + let amount = HumanByte::from(pull_stats.bytes); + let rate = HumanByte::new_binary( + pull_stats.bytes as f64 / pull_stats.elapsed.as_secs_f64(), + ); + task_log!( + worker, + "Summary: sync job pulled {amount} in {} chunks (average rate: {rate}/s)", + pull_stats.chunk_count, + ); + } else { + task_log!(worker, "Summary: sync job found no new data to pull"); + } task_log!(worker, "sync job '{}' end", &job_id);