add sys to se what we get
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user