Skip to content

Commit

Permalink
Fix divide by zero error while getting capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalNehra committed Dec 31, 2023
1 parent 38014fd commit a657fdc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions trashbin/src/main/java/com/amaze/trashbin/TrashBinMetadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ data class TrashBinMetadata(
var capacityNumOfFiles = 0
var capacityBytes = 0
if (config.retentionNumOfFiles != TrashBinConfig.RETENTION_NUM_OF_FILES) {
if (config.retentionNumOfFiles == 0) {
return 0
}
capacityNumOfFiles = (numOfFiles / config.retentionNumOfFiles) * 100
}
if (config.retentionBytes != TrashBinConfig.RETENTION_BYTES_INFINITE) {
if (config.retentionBytes == 0L) {
return 0
}
capacityBytes = ((totalBytes / config.retentionBytes) * 100).toInt()
}
return if (capacityBytes > capacityNumOfFiles) {
Expand Down

0 comments on commit a657fdc

Please sign in to comment.