Admin page: show actual file presence dot per row

This commit is contained in:
root
2026-03-23 16:47:20 +01:00
parent a3348e8795
commit 50fa003842
2 changed files with 57 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package web
import (
"ResendIt/internal/file"
"os"
"strconv"
"github.com/gin-gonic/gin"
@@ -70,10 +71,35 @@ func (h *Handler) AdminPage(c *gin.Context) {
return
}
// Only check files on the current page.
// Status meanings:
// - green: file exists on disk
// - red: file missing
// - rainbow: stat error (something unexpected)
type AdminFileView struct {
file.FileRecord
ActualStatus string
}
adminFiles := make([]AdminFileView, 0, len(files))
for _, f := range files {
status := "red"
if f.Path != "" {
if _, err := os.Stat(f.Path); err == nil {
status = "green"
} else if os.IsNotExist(err) {
status = "red"
} else {
status = "rainbow"
}
}
adminFiles = append(adminFiles, AdminFileView{FileRecord: f, ActualStatus: status})
}
totalPages := (totalCount + limit - 1) / limit
c.HTML(200, "admin.html", gin.H{
"Files": files,
"Files": adminFiles,
"Page": page,
"TotalPages": totalPages,
})