replace progress percentage with actual file size
This commit is contained in:
22
app/misc.go
22
app/misc.go
@@ -1,19 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
import "fmt"
|
||||
|
||||
// Helper function to create string pointer
|
||||
func ptr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
const progressBarLength = 20
|
||||
|
||||
func renderProgressBar(percent float64) string {
|
||||
filled := int(float64(progressBarLength) * percent / 100)
|
||||
bar := strings.Repeat("█", filled) + strings.Repeat(" ", progressBarLength-filled)
|
||||
return fmt.Sprintf("[%s] %.0f%%", bar, percent)
|
||||
func formatBytes(b int) string {
|
||||
switch {
|
||||
case b >= 1<<30:
|
||||
return fmt.Sprintf("%.1f GB", float64(b)/float64(1<<30))
|
||||
case b >= 1<<20:
|
||||
return fmt.Sprintf("%.1f MB", float64(b)/float64(1<<20))
|
||||
case b >= 1<<10:
|
||||
return fmt.Sprintf("%.1f KB", float64(b)/float64(1<<10))
|
||||
default:
|
||||
return fmt.Sprintf("%d B", b)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user