Umstellung auf uuid
All checks were successful
release-tag / release-image (push) Successful in 1m32s

This commit is contained in:
2025-09-27 21:42:32 +02:00
parent 92e222f648
commit baedff9e9d
6 changed files with 108 additions and 88 deletions

View File

@@ -56,17 +56,11 @@ func Register(mux *http.ServeMux, d Deps) {
// Partials
mux.HandleFunc("/admin/items", func(w http.ResponseWriter, r *http.Request) {
nextQ := strings.TrimSpace(r.URL.Query().Get("next"))
var nextID filesvc.ID
if nextQ != "" {
if n, err := strconv.ParseInt(nextQ, 10, 64); err == nil {
nextID = filesvc.ID(n)
}
}
nextID := filesvc.ID(strings.TrimSpace(r.URL.Query().Get("next")))
items, nextOut, _ := d.Store.List(r.Context(), nextID, 100)
type row struct {
ID int64
ID string
Name string
UpdatedAt int64
HasBlob bool
@@ -74,9 +68,9 @@ func Register(mux *http.ServeMux, d Deps) {
}
rows := make([]row, 0, len(items))
for _, it := range items {
meta, ok, _ := d.Blob.Stat(r.Context(), int64(it.ID))
meta, ok, _ := d.Blob.Stat(r.Context(), it.ID)
rows = append(rows, row{
ID: int64(it.ID),
ID: it.ID,
Name: it.Name,
UpdatedAt: it.UpdatedAt,
HasBlob: ok,
@@ -119,7 +113,7 @@ func Register(mux *http.ServeMux, d Deps) {
}
// 2) Blob speichern
if _, err := d.Blob.Save(r.Context(), int64(it.ID), name, fh); err != nil {
if _, err := d.Blob.Save(r.Context(), (it.ID), name, fh); err != nil {
// zurückrollen (Tombstone)
_, _ = d.Store.Delete(r.Context(), it.ID)
http.Error(w, "save failed: "+err.Error(), http.StatusInternalServerError)
@@ -137,8 +131,8 @@ func Register(mux *http.ServeMux, d Deps) {
http.NotFound(w, r)
return
}
id, err := strconv.ParseInt(parts[0], 10, 64)
if err != nil {
id := parts[0]
if strings.TrimSpace(id) == "" {
http.NotFound(w, r)
return
}
@@ -208,9 +202,9 @@ func Register(mux *http.ServeMux, d Deps) {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
idStr := r.FormValue("id")
id := strings.TrimSpace(r.FormValue("id"))
newName := strings.TrimSpace(r.FormValue("name"))
if id, err := strconv.ParseInt(idStr, 10, 64); err == nil && newName != "" {
if id != "" && newName != "" {
_, _ = d.Store.Rename(r.Context(), filesvc.ID(id), newName)
_ = d.Mesh.SyncNow(r.Context())
}
@@ -223,10 +217,10 @@ func Register(mux *http.ServeMux, d Deps) {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
id64, err := strconv.ParseInt(r.FormValue("id"), 10, 64)
if err == nil {
_, _ = d.Store.Delete(r.Context(), filesvc.ID(id64))
_ = d.Blob.Delete(r.Context(), id64) // Blob wirklich löschen
id := strings.TrimSpace(r.FormValue("id"))
if id != "" {
_, _ = d.Store.Delete(r.Context(), filesvc.ID(id))
_ = d.Blob.Delete(r.Context(), id)
_ = d.Mesh.SyncNow(r.Context())
}
renderItemsPartial(w, r, d)
@@ -264,27 +258,21 @@ func BasicAuth(user, pass string, next http.Handler) http.Handler {
// rebuild & render items partial for HTMX swaps
func renderItemsPartial(w http.ResponseWriter, r *http.Request, d Deps) {
type row struct {
ID int64
ID string
Name string
UpdatedAt int64
HasBlob bool
Size int64
}
nextQ := strings.TrimSpace(r.URL.Query().Get("next"))
var nextID filesvc.ID
if nextQ != "" {
if n, err := strconv.ParseInt(nextQ, 10, 64); err == nil {
nextID = filesvc.ID(n)
}
}
nextID := filesvc.ID(strings.TrimSpace(r.URL.Query().Get("next")))
items, nextOut, _ := d.Store.List(r.Context(), nextID, 100)
rows := make([]row, 0, len(items))
for _, it := range items {
meta, ok, _ := d.Blob.Stat(r.Context(), int64(it.ID))
meta, ok, _ := d.Blob.Stat(r.Context(), (it.ID))
rows = append(rows, row{
ID: int64(it.ID),
ID: (it.ID),
Name: it.Name,
UpdatedAt: it.UpdatedAt,
HasBlob: ok,