mirror of
https://github.com/rclone/rclone.git
synced 2025-02-22 17:07:59 +08:00
accounting: fix percentDiff calculation -- fixes #8345
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
This commit is contained in:
parent
b5e72e2fc3
commit
5d670fc54a
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user