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

@@ -203,13 +203,8 @@ func fileRoutes(mux *http.ServeMux, store filesvc.MeshStore, blobs blobfs.Store)
mux.HandleFunc("/api/v1/items", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
nextStr := r.URL.Query().Get("next")
var next filesvc.ID
if nextStr != "" {
if n, err := strconv.ParseInt(nextStr, 10, 64); err == nil {
next = filesvc.ID(n)
}
}
nextStr := strings.TrimSpace(r.URL.Query().Get("next"))
next := filesvc.ID(nextStr)
items, nextOut, err := store.List(r.Context(), next, 100)
if err != nil {
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
@@ -275,7 +270,7 @@ func fileRoutes(mux *http.ServeMux, store filesvc.MeshStore, blobs blobfs.Store)
return
}
it, err := store.Delete(r.Context(), in.ID)
_ = blobs.Delete(r.Context(), int64(in.ID))
_ = blobs.Delete(r.Context(), string(in.ID))
if err != nil {
status := http.StatusBadRequest
if errors.Is(err, filesvc.ErrNotFound) {
@@ -316,7 +311,7 @@ func apiFiles(mux *http.ServeMux, store filesvc.MeshStore, blobs blobfs.Store, m
writeJSON(w, http.StatusBadRequest, map[string]string{"error": err.Error()})
return
}
meta, err := blobs.Save(r.Context(), int64(it.ID), name, fh)
meta, err := blobs.Save(r.Context(), string(it.ID), name, fh)
if err != nil {
_, _ = store.Delete(r.Context(), it.ID)
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
@@ -336,8 +331,8 @@ func apiFiles(mux *http.ServeMux, store filesvc.MeshStore, blobs blobfs.Store, m
http.NotFound(w, r)
return
}
id, err := strconv.ParseInt(parts[0], 10, 64)
if err != nil || id <= 0 {
id := parts[0]
if strings.TrimSpace(id) == "" {
http.NotFound(w, r)
return
}
@@ -385,7 +380,7 @@ func toMeshSnapshot(s filesvc.Snapshot) mesh.Snapshot {
out := mesh.Snapshot{Items: make([]mesh.Item, 0, len(s.Items))}
for _, it := range s.Items {
out.Items = append(out.Items, mesh.Item{
ID: int64(it.ID),
ID: it.ID,
Name: it.Name,
UpdatedAt: it.UpdatedAt,
Deleted: it.Deleted,
@@ -398,7 +393,7 @@ func fromMeshSnapshot(ms mesh.Snapshot) filesvc.Snapshot {
out := filesvc.Snapshot{Items: make([]filesvc.File, 0, len(ms.Items))}
for _, it := range ms.Items {
out.Items = append(out.Items, filesvc.File{
ID: filesvc.ID(it.ID),
ID: it.ID,
Name: it.Name,
UpdatedAt: it.UpdatedAt,
Deleted: it.Deleted,
@@ -430,7 +425,7 @@ func main() {
ApplyRemote: func(ctx context.Context, s mesh.Snapshot) error {
return st.ApplyRemote(ctx, fromMeshSnapshot(s))
},
BlobOpen: func(ctx context.Context, id int64) (io.ReadCloser, string, string, int64, error) {
BlobOpen: func(ctx context.Context, id string) (io.ReadCloser, string, string, int64, error) { //5588
it, err := st.Get(ctx, filesvc.ID(id))
if err != nil || it.Deleted {
return nil, "", "", 0, fmt.Errorf("not found")
@@ -528,8 +523,8 @@ func registerPublicDownloads(mux *http.ServeMux, store filesvc.MeshStore, blobs
http.NotFound(w, r)
return
}
id, err := strconv.ParseInt(idStr, 10, 64)
if err != nil || id <= 0 {
id := idStr
if strings.TrimSpace(id) == "" {
http.NotFound(w, r)
return
}