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) { func listCartFiles(dir string) ([]CartFileInfo, error) {
entries, err := os.ReadDir(dir) entries, err := os.ReadDir(dir)
if err != nil { if err != nil {
@@ -40,18 +55,8 @@ func listCartFiles(dir string) ([]CartFileInfo, error) {
if e.IsDir() { if e.IsDir() {
continue continue
} }
name := e.Name() id, valid := isValidFileId(e.Name())
var idStr string if !valid {
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 {
continue continue
} }
@@ -59,11 +64,13 @@ func listCartFiles(dir string) ([]CartFileInfo, error) {
if err != nil { if err != nil {
continue continue
} }
info.Sys()
out = append(out, CartFileInfo{ out = append(out, CartFileInfo{
ID: idStr, ID: fmt.Sprintf("%d", id),
CartId: cart.CartId(id), CartId: cart.CartId(id),
Size: info.Size(), Size: info.Size(),
Modified: info.ModTime(), Modified: info.ModTime(),
System: info.Sys(),
}) })
} }
return out, nil return out, nil

View File

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