diff options
| author | historia <[not public]> | 2026-09-16 14:41:15 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-16 14:41:15 -0400 |
| commit | 9192d94dea6be5498ab080f3e2df5667af871d7a (patch) | |
| tree | e7aef3089d5d1e8da686c6b6ca9d4faeacb8b20b /internal/admin/api_files.go | |
| parent | 2f34e75f27e5f99cfc1c5f8eaf6ab4ff2fddb1d9 (diff) | |
| download | thehouseoficarus-9192d94dea6be5498ab080f3e2df5667af871d7a.tar.gz | |
fix: casino room eviction, session close race fix, open-payout recovery evidence
Diffstat (limited to 'internal/admin/api_files.go')
| -rw-r--r-- | internal/admin/api_files.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/admin/api_files.go b/internal/admin/api_files.go index f2ef928..ea75249 100644 --- a/internal/admin/api_files.go +++ b/internal/admin/api_files.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "path/filepath" + "strconv" "strings" ) @@ -20,6 +21,32 @@ func resolveDataPath(dataDir, relPath string) (string, error) { return filepath.Join(dataDir, clean), nil } +// evictDeletedRoomFile drops cached room state and any cached in-room games +// when the raw file manager deletes a room YAML (rooms/<dir>/<id>.yaml). +// Best-effort: only numeric .yaml stems under rooms/ count as room files. +func (s *AdminServer) evictDeletedRoomFile(relPath string) { + dir, base := filepath.Split(relPath) + idStr, ok := strings.CutSuffix(base, ".yaml") + if !ok || idStr == "" { + return + } + dir = strings.TrimSuffix(dir, "/") + if dir == "rooms" || strings.HasPrefix(dir, "rooms"+string(filepath.Separator)) { + id, err := strconv.Atoi(idStr) + if err != nil { + return + } + s.world.RebuildRoomIndex(s.dataDir) + s.world.ClearRoomState(id) + if s.mobStore != nil { + s.mobStore.RemoveMobsInRoom(id) + } + if s.evictRoom != nil { + s.evictRoom(id) + } + } +} + func (s *AdminServer) handleFileRename(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) @@ -204,6 +231,7 @@ func (s *AdminServer) handleFiles(w http.ResponseWriter, r *http.Request) { writeJSON(w, map[string]any{"error": "delete error: " + err.Error()}) return } + s.evictDeletedRoomFile(relPath) s.undoStack.Push(ChangeDesc{ Description: "Deleted file " + relPath, FilePath: fullPath, |
