refactor to remove ENABLE_SIZE_LIMIT option and replace it with -1 in the config.

This commit is contained in:
DmitryFrolovTri
2025-12-18 19:06:11 +00:00
parent 4ef0f996b3
commit 624fe24693
14 changed files with 123 additions and 88 deletions
+8
View File
@@ -12,6 +12,7 @@ import (
"fmt"
"hash"
"strconv"
"strings"
"time"
"code.gitea.io/gitea/modules/setting"
@@ -92,11 +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.
func GetFileSize(s string) (int64, error) {
s = strings.TrimSpace(s)
if s == "-1" {
return -1, nil
}
v, err := humanize.ParseBytes(s)
iv := int64(v)
return iv, err