Skip to content

Commit

Permalink
add var for corrupt index err
Browse files Browse the repository at this point in the history
  • Loading branch information
travisjeffery committed Dec 15, 2016
1 parent 36a5977 commit c00ca30
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions commitlog/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
"launchpad.net/gommap"
)

var (
ErrIndexCorrupt = errors.New("corrupt index file")
)

const (
offsetWidth = 4
offsetOffset = 0
Expand Down Expand Up @@ -175,15 +179,15 @@ func (idx *index) SanityCheck() error {
if idx.position == 0 {
return nil
} else if idx.position%entryWidth != 0 {
return errors.New("corrupt index file")
return ErrIndexCorrupt
} else {
//read last entry
entry := new(Entry)
if err := idx.ReadEntry(entry, idx.position-entryWidth); err != nil {
return err
}
if entry.Offset < idx.baseOffset {
return errors.New("corrupt index file")
return ErrIndexCorrupt
}
return nil
}
Expand Down

0 comments on commit c00ca30

Please sign in to comment.