mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +00:00
sftp: check for broken connection in Load/List operation
This commit is contained in:
parent
fc92a04284
commit
71c185313e
2 changed files with 17 additions and 0 deletions
9
changelog/unreleased/pull-5101
Normal file
9
changelog/unreleased/pull-5101
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Bugfix: Do not retry load/list operation is SFTP connection is broken
|
||||||
|
|
||||||
|
When using restic with the SFTP backend, backend operations that load
|
||||||
|
a file or list files were retried even if the SFTP connection is broken.
|
||||||
|
|
||||||
|
This has been fixed now.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/5101
|
||||||
|
https://forum.restic.net/t/restic-hanging-on-backup/8559/2
|
|
@ -391,6 +391,10 @@ func (r *SFTP) checkNoSpace(dir string, size int64, origErr error) error {
|
||||||
// Load runs fn with a reader that yields the contents of the file at h at the
|
// Load runs fn with a reader that yields the contents of the file at h at the
|
||||||
// given offset.
|
// given offset.
|
||||||
func (r *SFTP) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error {
|
func (r *SFTP) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error {
|
||||||
|
if err := r.clientError(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return util.DefaultLoad(ctx, h, length, offset, r.openReader, func(rd io.Reader) error {
|
return util.DefaultLoad(ctx, h, length, offset, r.openReader, func(rd io.Reader) error {
|
||||||
if length == 0 || !feature.Flag.Enabled(feature.BackendErrorRedesign) {
|
if length == 0 || !feature.Flag.Enabled(feature.BackendErrorRedesign) {
|
||||||
return fn(rd)
|
return fn(rd)
|
||||||
|
@ -460,6 +464,10 @@ func (r *SFTP) Remove(_ context.Context, h backend.Handle) error {
|
||||||
// List runs fn for each file in the backend which has the type t. When an
|
// List runs fn for each file in the backend which has the type t. When an
|
||||||
// error occurs (or fn returns an error), List stops and returns it.
|
// error occurs (or fn returns an error), List stops and returns it.
|
||||||
func (r *SFTP) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error {
|
func (r *SFTP) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error {
|
||||||
|
if err := r.clientError(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
basedir, subdirs := r.Basedir(t)
|
basedir, subdirs := r.Basedir(t)
|
||||||
walker := r.c.Walk(basedir)
|
walker := r.c.Walk(basedir)
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in a new issue