ci / check (push) Successful in 4m12s
- Boot chama ReconcileBlobs com log de órfãos (era código morto)
- treeNode/validTreeName/siblingDup/moveCreatesCycle compartilhados
entre Create/Update Category/Folder (mesma regra, um só lugar)
- mapStoreErrorFor com mensagens 404 por recurso (nota/arquivo/pasta/categoria)
- revisionHash helper + teste GET /revisions/{hash} (200 + 404)
- ReconcileBlobs com lock curto (coleta sob RLock, I/O fora do lock)
- AddFile com LimitReader no stream (cap antes de gravar, não depois)
- DeleteFile/DeleteFolder transacionais com rollback em memória
- attachmentKind único no frontend (syntax/html/preview)
- CI: gofmt, vet, test -race, node --check; go.mod 1.24 = Dockerfile
- README: notas operacionais (memória, proxy, boot, SSE, 413/400)
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
type categoryInput struct {
|
|
Name string `json:"name"`
|
|
Parent *string `json:"parent"` // ausente = não move; "" = raiz
|
|
}
|
|
|
|
func (s *Server) handleCreateCategory(w http.ResponseWriter, r *http.Request) {
|
|
var in categoryInput
|
|
if err := decodeJSON(w, r, &in, 1<<20); err != nil {
|
|
return
|
|
}
|
|
parent := ""
|
|
if in.Parent != nil {
|
|
parent = *in.Parent
|
|
}
|
|
c, err := s.st.CreateCategory(in.Name, parent)
|
|
if err != nil {
|
|
mapStoreErrorFor(w, err, "categoria")
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusCreated, c)
|
|
}
|
|
|
|
func (s *Server) handleUpdateCategory(w http.ResponseWriter, r *http.Request) {
|
|
var in categoryInput
|
|
if err := decodeJSON(w, r, &in, 1<<20); err != nil {
|
|
return
|
|
}
|
|
c, err := s.st.UpdateCategory(r.PathValue("id"), in.Name, in.Parent)
|
|
if err != nil {
|
|
mapStoreErrorFor(w, err, "categoria")
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, c)
|
|
}
|
|
|
|
func (s *Server) handleDeleteCategory(w http.ResponseWriter, r *http.Request) {
|
|
if err := s.st.DeleteCategory(r.PathValue("id")); err != nil {
|
|
mapStoreErrorFor(w, err, "categoria")
|
|
return
|
|
}
|
|
w.WriteHeader(http.StatusNoContent)
|
|
}
|