mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 02:48:55 +00:00
Merge pull request #4075 from greatroar/sftp-enospc
sftp: Fix ENOSPC check
This commit is contained in:
commit
4b98b5562d
12
changelog/unreleased/issue-3336
Normal file
12
changelog/unreleased/issue-3336
Normal file
@ -0,0 +1,12 @@
|
||||
Bugfix: SFTP backend now checks for disk space
|
||||
|
||||
A backup to an SFTP backend would spew repeated SSH_FX_FAILURE messages when
|
||||
the remote disk is full. Restic now reports "sftp: no space left on device"
|
||||
and exits immediately when it detects this condition.
|
||||
|
||||
A fix for this issue was promised in restic 0.12.1, but the fix itself
|
||||
contained a bug that prevented it from triggering.
|
||||
|
||||
https://github.com/restic/restic/issues/3336
|
||||
https://github.com/restic/restic/pull/3345
|
||||
https://github.com/restic/restic/pull/4075
|
@ -354,14 +354,13 @@ func (r *SFTP) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader
|
||||
debug.Log("sftp: failed to remove broken file %v: %v",
|
||||
f.Name(), rmErr)
|
||||
}
|
||||
|
||||
err = r.checkNoSpace(dirname, rd.Length(), err)
|
||||
}()
|
||||
|
||||
// save data, make sure to use the optimized sftp upload method
|
||||
wbytes, err := f.ReadFrom(rd)
|
||||
if err != nil {
|
||||
_ = f.Close()
|
||||
err = r.checkNoSpace(dirname, rd.Length(), err)
|
||||
return errors.Wrap(err, "Write")
|
||||
}
|
||||
|
||||
@ -403,7 +402,7 @@ func (r *SFTP) checkNoSpace(dir string, size int64, origErr error) error {
|
||||
debug.Log("sftp: StatVFS returned %v", err)
|
||||
return origErr
|
||||
}
|
||||
if fsinfo.Favail == 0 || fsinfo.FreeSpace() < uint64(size) {
|
||||
if fsinfo.Favail == 0 || fsinfo.Frsize*fsinfo.Bavail < uint64(size) {
|
||||
err := errors.New("sftp: no space left on device")
|
||||
return backoff.Permanent(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user