aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bolt.go6
-rw-r--r--bolt_linux.go2
-rw-r--r--tx.go2
3 files changed, 8 insertions, 2 deletions
diff --git a/bolt.go b/bolt.go
index c3a1bb5..a3f1eac 100644
--- a/bolt.go
+++ b/bolt.go
@@ -2,7 +2,11 @@
package bolt
-import "os"
+import (
+ "os"
+)
+
+var odirect int
func fdatasync(f *os.File) error {
return f.Sync()
diff --git a/bolt_linux.go b/bolt_linux.go
index 351b65a..4351db5 100644
--- a/bolt_linux.go
+++ b/bolt_linux.go
@@ -5,6 +5,8 @@ import (
"syscall"
)
+var odirect = syscall.O_DIRECT
+
func fdatasync(f *os.File) error {
return syscall.Fdatasync(int(f.Fd()))
}
diff --git a/tx.go b/tx.go
index 823b06d..8791adf 100644
--- a/tx.go
+++ b/tx.go
@@ -240,7 +240,7 @@ func (tx *Tx) close() {
// 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.Open(tx.db.path)
+ f, err := os.OpenFile(tx.db.path, os.O_RDONLY|odirect, 0)
if err != nil {
_ = tx.Rollback()
return err