Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

mount: Make fsync be a no-op rather than returning an error - fixes #1045

Nick Craig-Wood29c6e22024be
diff --git a/cmd/mount/file.go b/cmd/mount/file.go
index fb2f59f71..5958d9190 100644
--- a/cmd/mount/file.go
+++ b/cmd/mount/file.go
@@ -144,3 +144,13 @@ func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenR
*/
return nil, errors.New("can't figure out how to open")
}
+
+// Check interface satisfied
+var _ fusefs.NodeFsyncer = (*File)(nil)
+
+// Fsync the file
+//
+// Note that we don't do anything except return OK
+func (f *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
+ return nil
+}
diff --git a/cmd/mount/write_test.go b/cmd/mount/write_test.go
index 7c3d5c388..ee838c53f 100644
--- a/cmd/mount/write_test.go
+++ b/cmd/mount/write_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
// Test writing a file with no write()'s to it
@@ -101,3 +102,18 @@ func TestWriteFileDoubleClose(t *testing.T) {
run.rm(t, "testdoubleclose")
}
+
+// Test Fsync
+//
+// NB the code for this is in file.go rather than write.go
+func TestWriteFileFsync(t *testing.T) {
+ filepath := run.path("to be synced")
+ fd, err := os.Create(filepath)
+ require.NoError(t, err)
+ _, err = fd.Write([]byte("hello"))
+ require.NoError(t, err)
+ err = fd.Sync()
+ require.NoError(t, err)
+ err = fd.Close()
+ require.NoError(t, err)
+}