mirror of
https://github.com/rclone/rclone.git
synced 2025-06-03 18:53:16 +08:00
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:

committed by
Nick Craig-Wood

parent
a2c317b46e
commit
f78cd1e043
@ -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")
|
||||
|
Reference in New Issue
Block a user