issue/fix: (#51) consolidate storage #56
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements the storage refactor from mixed plain-text formats to a consistent JSON/JSONL-based layout under ~/.config/toofan/, including migration logic for existing users.
Changes:
- Replaces pipe-delimited
results.txtwith JSONLresults.jsonland updates profile parsing accordingly. - Consolidates
config.txt+pb.txtinto a singleconfig.jsonwith newConfigRecord/ResultRecordstructures. - Adds first-run migration in
internal/game/storage.goand updates internal documentation (AGENTS.md) to reflect the new formats.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/tui/profile.go | Reads results.jsonl and parses each line as JSON into a shared ResultRecord. |
| internal/game/storage.go | Introduces JSON/JSONL persistence, config+PB consolidation, and migration/backup updates. |
| AGENTS.md | Updates documentation to describe the new JSON/JSONL storage layout and migration behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+372
to
+374
| if err := os.Rename(oldRaces, newRaces); err != nil { | ||
| return | ||
| } |
Comment on lines
46
to
55
| configDir, err := os.UserConfigDir() | ||
| if err != nil { | ||
| return pd | ||
| } | ||
| dataDir := filepath.Join(configDir, "toofan") | ||
|
|
||
| f, err := os.Open(filepath.Join(dataDir, "results.txt")) | ||
| f, err := os.Open(filepath.Join(dataDir, "results.jsonl")) | ||
| if err != nil { | ||
| return pd | ||
| } |
- migration now removes config.txt, pb.txt, results.txt, races.txt after successful conversion (also handles leftover case where new json files already exist from a prior run) - backups use human-readable section format with .bak extension - existing .txt and .jsonl backups are converted to .bak on startup - restore handles both old and new backup formats via SplitBundle
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #55.
Consolidated Toofan user data from 4 mixed-format files to 3 consistent JSON-based files:
config.txt+pb.txt->config.jsonresults.txt->results.jsonlraces.txt->races.jsonl(same JSONL payload, extension/path corrected)This removes custom string parsing, unifies persistence format, and keeps append-only logs efficient.
New data layout