mirror of
https://github.com/restic/restic.git
synced 2025-10-09 07:33:53 +00:00
backend: pass context into every backend constructor
This commit is contained in:
@@ -36,7 +36,7 @@ const (
|
||||
)
|
||||
|
||||
// Open opens the REST backend with the given config.
|
||||
func Open(cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
func Open(_ context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
// use url without trailing slash for layout
|
||||
url := cfg.URL.String()
|
||||
if url[len(url)-1] == '/' {
|
||||
@@ -55,7 +55,7 @@ func Open(cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
|
||||
// Create creates a new REST on server configured in config.
|
||||
func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
be, err := Open(cfg, rt)
|
||||
be, err := Open(ctx, cfg, rt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -117,7 +117,7 @@ func TestListAPI(t *testing.T) {
|
||||
URL: srvURL,
|
||||
}
|
||||
|
||||
be, err := rest.Open(cfg, http.DefaultTransport)
|
||||
be, err := rest.Open(context.TODO(), cfg, http.DefaultTransport)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ func newTestSuite(_ context.Context, t testing.TB, url *url.URL, minimalData boo
|
||||
|
||||
// OpenFn is a function that opens a previously created temporary repository.
|
||||
Open: func(cfg rest.Config) (restic.Backend, error) {
|
||||
return rest.Open(cfg, tr)
|
||||
return rest.Open(context.TODO(), cfg, tr)
|
||||
},
|
||||
|
||||
// CleanupFn removes data created during the tests.
|
||||
|
Reference in New Issue
Block a user