diff --git a/weed/storage/backend/disk_file.go b/weed/storage/backend/disk_file.go index 050ded613..68ffbd7e7 100644 --- a/weed/storage/backend/disk_file.go +++ b/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 }