Fix OpenFile call flags for macos

This commit is contained in:
Andrey Beletsky 2021-07-15 18:23:06 +07:00 committed by Niko Storni
parent c6c779da39
commit 94e7d81bd3
3 changed files with 19 additions and 3 deletions

View file

@ -10,7 +10,6 @@ import (
"os"
"path"
"runtime"
"syscall"
"time"
"github.com/lbryio/reflector.go/shared"
@ -138,8 +137,7 @@ func (d *DiskStore) Put(hash string, blob stream.Blob) error {
}
// Open file with O_DIRECT
flags := os.O_WRONLY | os.O_CREATE | syscall.O_DIRECT
f, err := os.OpenFile(d.tmpPath(hash), flags, 0644)
f, err := os.OpenFile(d.tmpPath(hash), openFileFlags, 0644)
if err != nil {
return errors.Err(err)
}

9
store/flags_darwin.go Normal file
View file

@ -0,0 +1,9 @@
// +build darwin
package store
import (
"os"
)
var openFileFlags = os.O_WRONLY | os.O_CREATE

9
store/flags_linux.go Normal file
View file

@ -0,0 +1,9 @@
// +build linux
package store
import (
"os"
)
var openFileFlags = os.O_WRONLY | os.O_CREATE | syscall.O_DIRECT