refactor handling of -1 from base to business logic and UI for sizelimit working

This commit is contained in:
DmitryFrolovTri committed 2026-01-21 09:44:52 +00:00
1 parent 7942523c3f
commit c16ad5643a
8 files changed
+64 -48

No files matched your search

+5 -8
View File
@@ -93,21 +93,18 @@ func CreateTimeLimitCode[T time.Time | string](data string, minutes int, startTi
// FileSize calculates the file size and generate user-friendly string.
func FileSize(s int64) string {
if s == -1 {
return "-1"
}
return humanize.IBytes(uint64(s))
}
// Get FileSize bytes value from String.
// GetFileSize gets FileSize bytes value from String.
func GetFileSize(s string) (int64, error) {
s = strings.TrimSpace(s)
if s == "-1" {
return -1, nil
// default to bytes if no unit is provided
if _, err := strconv.ParseInt(s, 10, 64); err == nil {
s += " B"
}
v, err := humanize.ParseBytes(s)
iv := int64(v)
return iv, err
return int64(v), err
}
// StringsToInt64s converts a slice of string to a slice of int64.