diff options
Diffstat (limited to 'internal/admin/api_techs.go')
| -rw-r--r-- | internal/admin/api_techs.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/admin/api_techs.go b/internal/admin/api_techs.go index 9e742e1..d2c5f65 100644 --- a/internal/admin/api_techs.go +++ b/internal/admin/api_techs.go @@ -111,9 +111,16 @@ func (s *AdminServer) handleTechByID(w http.ResponseWriter, r *http.Request) { var oldContent []byte if !isCreate { - if existing, err := snapshotFile(path); err == nil { - oldContent = existing + existing, existed, err := snapshotBefore(path) + if err != nil { + failJSON(w, "read existing file: "+err.Error()) + return } + if !existed { + failJSON(w, "not found: "+id) + return + } + oldContent = existing } newContent, err := writeMapAsYAML(path, body) |
