mirror of
https://github.com/restic/restic.git
synced 2025-08-13 06:47:37 +00:00
rest: use global context on repository creation
This commit is contained in:
@@ -275,8 +275,8 @@ func Open(cfg Config, lim limiter.Limiter) (*Backend, error) {
|
||||
return be, nil
|
||||
}
|
||||
|
||||
// Create initializes a new restic repo with clone.
|
||||
func Create(cfg Config) (*Backend, error) {
|
||||
// Create initializes a new restic repo with rclone.
|
||||
func Create(ctx context.Context, cfg Config) (*Backend, error) {
|
||||
be, err := newBackend(cfg, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -294,7 +294,7 @@ func Create(cfg Config) (*Backend, error) {
|
||||
URL: url,
|
||||
}
|
||||
|
||||
restBackend, err := rest.Create(restConfig, debug.RoundTripper(be.tr))
|
||||
restBackend, err := rest.Create(ctx, restConfig, debug.RoundTripper(be.tr))
|
||||
if err != nil {
|
||||
_ = be.Close()
|
||||
return nil, err
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package rclone_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
@@ -27,7 +28,7 @@ func newTestSuite(t testing.TB) *test.Suite {
|
||||
Create: func(config interface{}) (restic.Backend, error) {
|
||||
t.Logf("Create()")
|
||||
cfg := config.(rclone.Config)
|
||||
be, err := rclone.Create(cfg)
|
||||
be, err := rclone.Create(context.TODO(), cfg)
|
||||
if e, ok := errors.Cause(err).(*exec.Error); ok && e.Err == exec.ErrNotFound {
|
||||
t.Skipf("program %q not found", e.Name)
|
||||
return nil, nil
|
||||
|
Reference in New Issue
Block a user