From e0a6f5b2af6a09ab42dc46748be9291a16895bc7 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Sun, 23 Mar 2014 13:20:53 -0700 Subject: 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. --- db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'db.go') 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. -- cgit v1.2.3