Skip to content

Commit

Permalink
fix: handle corrupted database file properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Diegiwg committed Jun 26, 2024
1 parent 0c27502 commit 6c68e30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.3.0
v1.3.1
7 changes: 6 additions & 1 deletion data/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ func ReadOrCreateRecord(ctx *cli.Context) model.RecordTable {

err = json.Unmarshal(fileContent, &table)
if err != nil {
panic(err)
println("Database file is corrupted. Creating new one.")

table = model.NewRecordTable()
table.Add(model.NewRecord())

SaveRecordToFile(ctx, &table)
}

return table
Expand Down

0 comments on commit 6c68e30

Please sign in to comment.