Check errors from file close in DB.CopyFile

Write errors are often delayed and reported only by the close.

The extra close in defer on success is harmless, (*os.File).Close
protects itself against multiple closes, and this way it's immediately
obvious there is no code path that would leak open files.
master
Tommi Virtanen 2014-03-23 13:20:53 -07:00
parent cb896f6525
commit e0a6f5b2af
1 changed files with 5 additions and 1 deletions

6
db.go
View File

@ -432,7 +432,11 @@ func (db *DB) CopyFile(path string, mode os.FileMode) error {
} }
defer f.Close() defer f.Close()
return db.Copy(f) err = db.Copy(f)
if err != nil {
return err
}
return f.Close()
} }
// Stat retrieves stats on the database and its page usage. // Stat retrieves stats on the database and its page usage.