mirror of
https://github.com/restic/restic.git
synced 2025-03-11 14:48:03 +00:00
retry load or creating repository config
By now missing files are not endlessly retried by the retry backend such that it can be enabled right from the start. In addition, this change also enables the retry backend for the `init` command.
This commit is contained in:
parent
fc92a04284
commit
74c783b850
1 changed files with 20 additions and 21 deletions
|
@ -439,26 +439,6 @@ func OpenRepository(ctx context.Context, opts GlobalOptions) (*repository.Reposi
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
report := func(msg string, err error, d time.Duration) {
|
|
||||||
if d >= 0 {
|
|
||||||
Warnf("%v returned error, retrying after %v: %v\n", msg, d, err)
|
|
||||||
} else {
|
|
||||||
Warnf("%v failed: %v\n", msg, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
success := func(msg string, retries int) {
|
|
||||||
Warnf("%v operation successful after %d retries\n", msg, retries)
|
|
||||||
}
|
|
||||||
be = retry.New(be, 15*time.Minute, report, success)
|
|
||||||
|
|
||||||
// wrap backend if a test specified a hook
|
|
||||||
if opts.backendTestHook != nil {
|
|
||||||
be, err = opts.backendTestHook(be)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s, err := repository.New(be, repository.Options{
|
s, err := repository.New(be, repository.Options{
|
||||||
Compression: opts.Compression,
|
Compression: opts.Compression,
|
||||||
PackSize: opts.PackSize * 1024 * 1024,
|
PackSize: opts.PackSize * 1024 * 1024,
|
||||||
|
@ -629,12 +609,31 @@ func innerOpen(ctx context.Context, s string, gopts GlobalOptions, opts options.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report := func(msg string, err error, d time.Duration) {
|
||||||
|
if d >= 0 {
|
||||||
|
Warnf("%v returned error, retrying after %v: %v\n", msg, d, err)
|
||||||
|
} else {
|
||||||
|
Warnf("%v failed: %v\n", msg, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
success := func(msg string, retries int) {
|
||||||
|
Warnf("%v operation successful after %d retries\n", msg, retries)
|
||||||
|
}
|
||||||
|
be = retry.New(be, 15*time.Minute, report, success)
|
||||||
|
|
||||||
|
// wrap backend if a test specified a hook
|
||||||
|
if gopts.backendTestHook != nil {
|
||||||
|
be, err = gopts.backendTestHook(be)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return be, nil
|
return be, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the backend specified by a location config.
|
// Open the backend specified by a location config.
|
||||||
func open(ctx context.Context, s string, gopts GlobalOptions, opts options.Options) (backend.Backend, error) {
|
func open(ctx context.Context, s string, gopts GlobalOptions, opts options.Options) (backend.Backend, error) {
|
||||||
|
|
||||||
be, err := innerOpen(ctx, s, gopts, opts, false)
|
be, err := innerOpen(ctx, s, gopts, opts, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Add table
Reference in a new issue