Skip to content

Commit

Permalink
Disable panic on truncated raftdb when index is not explicitly passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranjandas committed Nov 21, 2022
1 parent 8e0f4e6 commit fcf98c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ var printCmd = &cobra.Command{
log.Fatalf("unable to read Raft file: %s", err)
}

if start < store.FirstIndex || end > store.LastIndex {
log.Fatalf("allowed range: [%d, %d]", store.FirstIndex, store.LastIndex)
// set the start to stores FirstIndex if out of range
if start < store.FirstIndex {
start = store.FirstIndex
}

// default to print all logs
if end == 0 {
if end > store.LastIndex || end == 0 {
end = store.LastIndex
}

Expand Down

0 comments on commit fcf98c2

Please sign in to comment.