diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-05 10:18:58 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-05 10:18:58 -0600 |
commit | 9ffb29787a062e01dae4370a824453ff65b7bf58 (patch) | |
tree | 0df145b27d723bde29cf7c851d12dde2a0f353fc | |
parent | Merge pull request #181 from benbjohnson/split-merge (diff) | |
parent | Add fallback for O_DIRECT in Tx.Copy(). (diff) | |
download | dedo-9ffb29787a062e01dae4370a824453ff65b7bf58.tar.gz dedo-9ffb29787a062e01dae4370a824453ff65b7bf58.tar.xz |
Merge pull request #183 from benbjohnson/copy-fallback
Add fallback for O_DIRECT in Tx.Copy().
-rw-r--r-- | tx.go | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -239,10 +239,15 @@ func (tx *Tx) close() { // using the database while a copy is in progress. // Copy will write exactly tx.Size() bytes into the writer. func (tx *Tx) Copy(w io.Writer) error { - // Open reader on the database. - f, err := os.OpenFile(tx.db.path, os.O_RDONLY|odirect, 0) - if err != nil { - return err + var f *os.File + var err error + + // Attempt to open reader directly. + if f, err = os.OpenFile(tx.db.path, os.O_RDONLY|odirect, 0); err != nil { + // Fallback to a regular open if that doesn't work. + if f, err = os.OpenFile(tx.db.path, os.O_RDONLY, 0); err != nil { + return err + } } // Copy the meta pages. |