fix(nfs): reconcile clients[i].advanced type mismatch (object vs string)
backend: db.NFSClient.Advanced is db.NFSAdvanced (struct → JSON object) handler: nfsClientRequest.Advanced was string → now db.NFSAdvanced frontend: api.ts NFSClient.advanced string → NFSAdvanced (object) frontend: Nfs.tsx updated to work with object advanced per host Without this fix, editing an existing NFS export with per-host options (loaded from DB via migration 0005) would 400 on PUT because the backend expected a string but received a JSON object.
This commit is contained in:
@@ -14,12 +14,12 @@ import (
|
||||
)
|
||||
|
||||
type nfsClientRequest struct {
|
||||
Host string `json:"host"`
|
||||
ReadOnly bool `json:"read_only"`
|
||||
Async bool `json:"async"`
|
||||
RootSquash bool `json:"root_squash"`
|
||||
SubtreeCheck bool `json:"subtree_check"`
|
||||
Advanced string `json:"advanced"`
|
||||
Host string `json:"host"`
|
||||
ReadOnly bool `json:"read_only"`
|
||||
Async bool `json:"async"`
|
||||
RootSquash bool `json:"root_squash"`
|
||||
SubtreeCheck bool `json:"subtree_check"`
|
||||
Advanced db.NFSAdvanced `json:"advanced"`
|
||||
}
|
||||
|
||||
type nfsExportRequest struct {
|
||||
@@ -54,7 +54,7 @@ func (req nfsExportRequest) toModel() db.NFSExport {
|
||||
Async: c.Async,
|
||||
RootSquash: c.RootSquash,
|
||||
SubtreeCheck: c.SubtreeCheck,
|
||||
Advanced: parseNFSAdvanced(c.Advanced),
|
||||
Advanced: c.Advanced,
|
||||
})
|
||||
}
|
||||
return db.NFSExport{
|
||||
@@ -68,15 +68,6 @@ func (req nfsExportRequest) toModel() db.NFSExport {
|
||||
}
|
||||
}
|
||||
|
||||
func parseNFSAdvanced(raw string) db.NFSAdvanced {
|
||||
var adv db.NFSAdvanced
|
||||
if raw == "" || raw == "{}" {
|
||||
return adv
|
||||
}
|
||||
_ = json.Unmarshal([]byte(raw), &adv)
|
||||
return adv
|
||||
}
|
||||
|
||||
func (s *Server) handleListNFSExports(w http.ResponseWriter, r *http.Request) {
|
||||
exports, err := s.DB.ListNFSExports()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user