Add context propagation to rclone

- Change rclone/fs interfaces to accept context.Context
- Update interface implementations to use context.Context
- Change top level usage to propagate context to lover level functions

Context propagation is needed for stopping transfers and passing other
request-scoped values.
This commit is contained in:
Aleksandar Jankovic
2019-06-17 10:34:30 +02:00
committed by Nick Craig-Wood
parent a2c317b46e
commit f78cd1e043
156 changed files with 2570 additions and 2380 deletions

View File

@ -3,6 +3,7 @@
package vfs
import (
"context"
"io"
"os"
"testing"
@ -130,8 +131,8 @@ func TestVFSStat(t *testing.T) {
defer r.Finalise()
vfs := New(r.Fremote, nil)
file1 := r.WriteObject("file1", "file1 contents", t1)
file2 := r.WriteObject("dir/file2", "file2 contents", t2)
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
fstest.CheckItems(t, r.Fremote, file1, file2)
node, err := vfs.Stat("file1")
@ -167,8 +168,8 @@ func TestVFSStatParent(t *testing.T) {
defer r.Finalise()
vfs := New(r.Fremote, nil)
file1 := r.WriteObject("file1", "file1 contents", t1)
file2 := r.WriteObject("dir/file2", "file2 contents", t2)
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
fstest.CheckItems(t, r.Fremote, file1, file2)
node, leaf, err := vfs.StatParent("file1")
@ -201,8 +202,8 @@ func TestVFSOpenFile(t *testing.T) {
defer r.Finalise()
vfs := New(r.Fremote, nil)
file1 := r.WriteObject("file1", "file1 contents", t1)
file2 := r.WriteObject("dir/file2", "file2 contents", t2)
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
fstest.CheckItems(t, r.Fremote, file1, file2)
fd, err := vfs.OpenFile("file1", os.O_RDONLY, 0777)
@ -238,7 +239,7 @@ func TestVFSRename(t *testing.T) {
}
vfs := New(r.Fremote, nil)
file1 := r.WriteObject("dir/file2", "file2 contents", t2)
file1 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
fstest.CheckItems(t, r.Fremote, file1)
err := vfs.Rename("dir/file2", "dir/file1")