Browse Source

fix: always close volume file (#4530) (#5459)

If sync fails then close is never called. We should always be calling
close on the file.

Co-authored-by: Hendrik Appel <happel@europe.altair.com>
pull/5462/head
Henco Appel 9 months ago
committed by GitHub
parent
commit
2a88da4de7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      weed/storage/backend/disk_file.go

15
weed/storage/backend/disk_file.go

@ -81,13 +81,20 @@ func (df *DiskFile) Close() error {
if df.File == nil {
return nil
}
if err := df.Sync(); err != nil {
return err
err := df.Sync()
var err1 error
if df.File != nil {
// always try to close
err1 = df.File.Close()
}
if err := df.File.Close(); err != nil {
// assume closed
df.File = nil
if err != nil {
return err
}
df.File = nil
if err1 != nil {
return err1
}
return nil
}

Loading…
Cancel
Save