diff options
author | Tommi Virtanen <tv@eagain.net> | 2014-03-23 13:20:53 -0700 |
---|---|---|
committer | Tommi Virtanen <tv@eagain.net> | 2014-03-23 13:27:37 -0700 |
commit | e0a6f5b2af6a09ab42dc46748be9291a16895bc7 (patch) | |
tree | 65033a21d6f429272ccf1a3751d5383e39e50d46 /db.go | |
parent | Check spill error in Commit (diff) | |
download | dedo-e0a6f5b2af6a09ab42dc46748be9291a16895bc7.tar.gz dedo-e0a6f5b2af6a09ab42dc46748be9291a16895bc7.tar.xz |
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.
Diffstat (limited to 'db.go')
-rw-r--r-- | db.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -432,7 +432,11 @@ func (db *DB) CopyFile(path string, mode os.FileMode) error { } 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. |