mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
vfs: add --vfs-writeback option to delay writes back to cloud storage
This is enabled by default and can be disabled with --vfs-writeback 0
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
||||
)
|
||||
|
||||
// Open a file for write
|
||||
func readHandleCreate(t *testing.T, r *fstest.Run) (*VFS, *ReadFileHandle) {
|
||||
vfs := New(r.Fremote, nil)
|
||||
func readHandleCreate(t *testing.T) (r *fstest.Run, vfs *VFS, fh *ReadFileHandle, cleanup func()) {
|
||||
r, vfs, cleanup = newTestVFS(t)
|
||||
|
||||
file1 := r.WriteObject(context.Background(), "dir/file1", "0123456789abcdef", t1)
|
||||
fstest.CheckItems(t, r.Fremote, file1)
|
||||
@@ -23,7 +23,7 @@ func readHandleCreate(t *testing.T, r *fstest.Run) (*VFS, *ReadFileHandle) {
|
||||
fh, ok := h.(*ReadFileHandle)
|
||||
require.True(t, ok)
|
||||
|
||||
return vfs, fh
|
||||
return r, vfs, fh, cleanup
|
||||
}
|
||||
|
||||
// read data from the string
|
||||
@@ -37,9 +37,8 @@ func readString(t *testing.T, fh *ReadFileHandle, n int) string {
|
||||
}
|
||||
|
||||
func TestReadFileHandleMethods(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
defer r.Finalise()
|
||||
_, fh := readHandleCreate(t, r)
|
||||
_, _, fh, cleanup := readHandleCreate(t)
|
||||
defer cleanup()
|
||||
|
||||
// String
|
||||
assert.Equal(t, "dir/file1 (r)", fh.String())
|
||||
@@ -81,9 +80,8 @@ func TestReadFileHandleMethods(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadFileHandleSeek(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
defer r.Finalise()
|
||||
_, fh := readHandleCreate(t, r)
|
||||
_, _, fh, cleanup := readHandleCreate(t)
|
||||
defer cleanup()
|
||||
|
||||
assert.Equal(t, "0", readString(t, fh, 1))
|
||||
|
||||
@@ -125,9 +123,8 @@ func TestReadFileHandleSeek(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadFileHandleReadAt(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
defer r.Finalise()
|
||||
_, fh := readHandleCreate(t, r)
|
||||
_, _, fh, cleanup := readHandleCreate(t)
|
||||
defer cleanup()
|
||||
|
||||
// read from start
|
||||
buf := make([]byte, 1)
|
||||
@@ -182,9 +179,8 @@ func TestReadFileHandleReadAt(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadFileHandleFlush(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
defer r.Finalise()
|
||||
_, fh := readHandleCreate(t, r)
|
||||
_, _, fh, cleanup := readHandleCreate(t)
|
||||
defer cleanup()
|
||||
|
||||
// Check Flush does nothing if read not called
|
||||
err := fh.Flush()
|
||||
@@ -212,9 +208,8 @@ func TestReadFileHandleFlush(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadFileHandleRelease(t *testing.T) {
|
||||
r := fstest.NewRun(t)
|
||||
defer r.Finalise()
|
||||
_, fh := readHandleCreate(t, r)
|
||||
_, _, fh, cleanup := readHandleCreate(t)
|
||||
defer cleanup()
|
||||
|
||||
// Check Release does nothing if file not read from
|
||||
err := fh.Release()
|
||||
|
||||
Reference in New Issue
Block a user