1
0
mirror of https://github.com/taigrr/bitcask synced 2025-01-18 04:03:17 -08:00

Fix recoverDatafile error covering (#162)

This commit is contained in:
chenbc 2020-06-17 13:06:30 +08:00 committed by GitHub
parent 1ef3cde964
commit afdf956e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,7 +43,10 @@ func recoverDatafile(path string, cfg *config.Config) (recovered bool, err error
return false, fmt.Errorf("opening the datafile: %s", err)
}
defer func() {
err = f.Close()
closeErr := f.Close()
if err == nil {
err = closeErr
}
}()
_, file := filepath.Split(path)
rPath := fmt.Sprintf("%s.recovered", file)
@ -52,7 +55,10 @@ func recoverDatafile(path string, cfg *config.Config) (recovered bool, err error
return false, fmt.Errorf("creating the recovered datafile: %w", err)
}
defer func() {
err = fr.Close()
closeErr := fr.Close()
if err == nil {
err = closeErr
}
}()
dec := codec.NewDecoder(f, cfg.MaxKeySize, cfg.MaxValueSize)