From 5b28c3f728cef64d8469c34860363f17d70a90f4 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Mon, 10 Oct 2022 19:28:02 +0500 Subject: [PATCH] revert disabling FSync for non Mac (#3814) --- weed/storage/backend/disk_file.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/weed/storage/backend/disk_file.go b/weed/storage/backend/disk_file.go index 0dd153d5d..7a3a40977 100644 --- a/weed/storage/backend/disk_file.go +++ b/weed/storage/backend/disk_file.go @@ -4,6 +4,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/glog" . "github.com/seaweedfs/seaweedfs/weed/storage/types" "os" + "runtime" "time" ) @@ -11,6 +12,8 @@ var ( _ BackendStorageFile = &DiskFile{} ) +const isMac = runtime.GOOS == "darwin" + type DiskFile struct { File *os.File fullFilePath string @@ -81,6 +84,11 @@ func (df *DiskFile) Name() string { } func (df *DiskFile) Sync() error { - return nil - // return df.File.Sync() + if df.File == nil { + return os.ErrInvalid + } + if isMac { + return nil + } + return df.File.Sync() }