Skip to content

Commit

Permalink
Fix division by zero error in formatFileRow (#359)
Browse files Browse the repository at this point in the history
Co-authored-by: Rober <rober@arch>
  • Loading branch information
xroberx and Rober committed May 9, 2024
1 parent 7af730c commit 55b21a1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tui/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ const (
)

func (ui *UI) formatFileRow(item fs.Item, maxUsage, maxSize int64, marked, ignored bool) string {
var part int

switch {
case ignored:
part = 0
case ui.ShowApparentSize:
part = int(float64(item.GetSize()) / float64(maxSize) * 100.0)
default:
part = int(float64(item.GetUsage()) / float64(maxUsage) * 100.0)
part := 0
if !ignored {
if ui.ShowApparentSize {
if size := item.GetSize(); size > 0 {
part = int(float64(size) / float64(maxSize) * 100.0)
}
} else {
if usage := item.GetUsage(); usage > 0 {
part = int(float64(usage) / float64(maxUsage) * 100.0)
}
}
}

row := string(item.GetFlag())
Expand Down

0 comments on commit 55b21a1

Please sign in to comment.