mirror of https://github.com/hak5/bolt.git
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
parent
cb896f6525
commit
e0a6f5b2af
6
db.go
6
db.go
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue