From 153acb7f644d755c45533b7c5311e3ffa47e8973 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 05:31:09 -0400 Subject: fix: harden engine across casino, economy, concurrency, security, and content --- internal/admin/api_triggers.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'internal/admin/api_triggers.go') diff --git a/internal/admin/api_triggers.go b/internal/admin/api_triggers.go index 5b82465..08e2855 100644 --- a/internal/admin/api_triggers.go +++ b/internal/admin/api_triggers.go @@ -147,12 +147,21 @@ func (s *AdminServer) handleTriggerByID(w http.ResponseWriter, r *http.Request) os.Remove(oldPath) } - s.undoStack.Push(ChangeDesc{ + desc := ChangeDesc{ Description: "Update trigger " + id, FilePath: newPath, OldContent: oldContent, NewContent: triggerData, - }) + } + if findErr == nil && newSubdir != oldDir { + // A kind change moves the file between subdirectories. Record the + // old path as the before-image location so undo restores the old + // content there (and removes the new file) instead of writing the + // old content into the new directory and orphaning the old path. + desc.FilePath = oldPath + desc.NewFilePath = newPath + } + s.undoStack.Push(desc) s.rebuildTriggerIndex() writeJSON(w, map[string]any{"ok": true, "id": id, "kind": newKind}) -- cgit v1.2.3