feature/backoffice #6

Merged
mats merged 24 commits from feature/backoffice into main 2025-10-16 09:46:07 +02:00
2 changed files with 21 additions and 13 deletions
Showing only changes of commit 1c589e0558 - Show all commits

View File

@@ -27,6 +27,21 @@ func NewFileServer(dataDir string) *FileServer {
}
}
func isValidFileId(name string) (uint64, bool) {
parts := strings.Split(name, ".")
if len(parts) > 1 && parts[1] == "events" {
idStr := parts[0]
if _, err := strconv.ParseUint(idStr, 10, 64); err != nil {
return 0, false
}
if id, err := strconv.ParseUint(idStr, 10, 64); err == nil {
return id, true
}
}
return 0, false
}
func listCartFiles(dir string) ([]CartFileInfo, error) {
entries, err := os.ReadDir(dir)
if err != nil {
@@ -40,18 +55,8 @@ func listCartFiles(dir string) ([]CartFileInfo, error) {
if e.IsDir() {
continue
}
name := e.Name()
var idStr string
var id uint64
var parseErr error
parts := strings.Split(name, ".")
if len(parts) > 1 && parts[1] == "events" {
idStr = parts[0]
id, parseErr = strconv.ParseUint(idStr, 10, 64)
} else {
continue
}
if parseErr != nil {
id, valid := isValidFileId(e.Name())
if !valid {
continue
}
@@ -59,11 +64,13 @@ func listCartFiles(dir string) ([]CartFileInfo, error) {
if err != nil {
continue
}
info.Sys()
out = append(out, CartFileInfo{
ID: idStr,
ID: fmt.Sprintf("%d", id),
CartId: cart.CartId(id),
Size: info.Size(),
Modified: info.ModTime(),
System: info.Sys(),
})
}
return out, nil

View File

@@ -21,6 +21,7 @@ type CartFileInfo struct {
CartId cart.CartId `json:"cartId"`
Size int64 `json:"size"`
Modified time.Time `json:"modified"`
System any `json:"system"`
}
func envOrDefault(key, def string) string {