Skip to content

Commit

Permalink
Merge pull request #26 from percona/master
Browse files Browse the repository at this point in the history
Return real error from Erase()
  • Loading branch information
peterbourgon committed Nov 13, 2015
2 parents f726c97 + 0cf225b commit f2c8925
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions diskv.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,15 @@ func (d *Diskv) Erase(key string) error {
// erase from disk
filename := d.completeFilename(key)
if s, err := os.Stat(filename); err == nil {
if !!s.IsDir() {
if s.IsDir() {
return errBadKey
}
if err = os.Remove(filename); err != nil {
return fmt.Errorf("remove: %s", err)
return err
}
} else {
return fmt.Errorf("stat: %s", err)
// Return err as-is so caller can do os.IsNotExist(err).
return err
}

// clean up and return
Expand Down

0 comments on commit f2c8925

Please sign in to comment.