diff options
| author | historia <[not public]> | 2026-09-18 20:03:13 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 20:03:13 -0400 |
| commit | 79764732406d6484f67d3dec045483dcb5d08c28 (patch) | |
| tree | 7a64e8581a540b97ed554f5723e2d587424ab1c6 /internal/admin/api_room_courses.go | |
| parent | f1e461ab6aec6b9bf056bbe2daa88a251e0f21da (diff) | |
| download | thehouseoficarus-79764732406d6484f67d3dec045483dcb5d08c28.tar.gz | |
feat: better card ascii art
Diffstat (limited to 'internal/admin/api_room_courses.go')
| -rw-r--r-- | internal/admin/api_room_courses.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/admin/api_room_courses.go b/internal/admin/api_room_courses.go index 5a33e6a..db74adf 100644 --- a/internal/admin/api_room_courses.go +++ b/internal/admin/api_room_courses.go @@ -204,16 +204,17 @@ func (s *AdminServer) handleCourseByID(w http.ResponseWriter, r *http.Request) { delete(body, "_raw") delete(body, "_path") - var oldContent []byte - if existing, err := snapshotFile(path); err == nil { - oldContent = existing + oldContent, existed, err := snapshotBefore(path) + if err != nil { + failJSON(w, "read existing file: "+err.Error()) + return } newContent, err := writeMapAsYAML(path, body) if err != nil { failJSON(w, "write error: "+err.Error()) return } - isCreate := oldContent == nil + isCreate := !existed desc := "Updated course " + id if isCreate { desc = "Created course " + id |
