aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2014-03-23 13:20:53 -0700
committerTommi Virtanen <tv@eagain.net>2014-03-23 13:27:37 -0700
commite0a6f5b2af6a09ab42dc46748be9291a16895bc7 (patch)
tree65033a21d6f429272ccf1a3751d5383e39e50d46 /db.go
parentCheck spill error in Commit (diff)
downloaddedo-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.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/db.go b/db.go
index 0bce184..ab7c5a1 100644
--- a/db.go
+++ b/db.go
@@ -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.