1
mirror of https://github.com/rclone/rclone synced 2024-11-07 04:16:58 +01:00

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

This commit is contained in:
Nick Craig-Wood 2017-01-29 11:29:42 +00:00
parent 390f3cf35b
commit 29c6e22024
2 changed files with 26 additions and 0 deletions

View File

@ -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
}

View File

@ -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)
}