1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

accounting: fix percentDiff calculation -- fixes #8345

Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
This commit is contained in:
Anagh Kumar Baranwal
2025-02-13 17:09:24 +05:30
committed by Nick Craig-Wood
parent b5e72e2fc3
commit 5d670fc54a

View File

@@ -237,5 +237,14 @@ func TestCountError(t *testing.T) {
}
func percentDiff(start, end uint64) uint64 {
return (start - end) * 100 / start
if start == 0 {
return 0 // Handle zero start value to avoid division by zero
}
var diff uint64
if end > start {
diff = end - start // Handle case where end is larger than start
} else {
diff = start - end
}
return (diff * 100) / start
}