diff options
| author | historia <[not public]> | 2026-10-05 17:31:50 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-05 17:31:50 -0400 |
| commit | 516fd29da423432ef6dfded21a984f1d15dcab1a (patch) | |
| tree | eb2dabe325a1335dedac28a93453df643ef986f2 /internal/persistence/txn.go | |
| parent | e42952469dadfb3535633c66c881050ac128703c (diff) | |
| download | thehouseoficarus-516fd29da423432ef6dfded21a984f1d15dcab1a.tar.gz | |
fix: slop casino and economy fixes
Diffstat (limited to 'internal/persistence/txn.go')
| -rw-r--r-- | internal/persistence/txn.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/internal/persistence/txn.go b/internal/persistence/txn.go index 1049077..a12e227 100644 --- a/internal/persistence/txn.go +++ b/internal/persistence/txn.go @@ -406,7 +406,16 @@ func Recover(journalDir string) error { return err } for _, e := range entries { - if e.IsDir() || !hasSuffix(e.Name(), ".json") { + if e.IsDir() { + continue + } + if hasPrefix(e.Name(), ".save-") { + // A crash during a journal write leaves an atomic-writer temp + // behind; it is never a valid journal, so sweep it. + os.Remove(filepath.Join(journalDir, e.Name())) + continue + } + if !hasSuffix(e.Name(), ".json") { continue } path := filepath.Join(journalDir, e.Name()) @@ -445,6 +454,10 @@ func hasSuffix(s, suffix string) bool { return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix } +func hasPrefix(s, prefix string) bool { + return len(s) >= len(prefix) && s[:len(prefix)] == prefix +} + // ListJournalFiles is a debugging helper: returns sorted journal file names. func ListJournalFiles(journalDir string) ([]string, error) { entries, err := os.ReadDir(journalDir) |
