mirror of
https://github.com/octoleo/restic.git
synced 2025-01-03 07:12:28 +00:00
sftp: Fix ENOSPC check
We now check for space that is not reserved for the root user on the remote, and the check is no longer in a defer block because it wouldn't fire. Some change in the surrounding code may have led the deferred function to capture the wrong err variable. Fixes #3336.
This commit is contained in:
parent
57d8eedb88
commit
62520bb7b4
@ -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",
|
debug.Log("sftp: failed to remove broken file %v: %v",
|
||||||
f.Name(), rmErr)
|
f.Name(), rmErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = r.checkNoSpace(dirname, rd.Length(), err)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// save data, make sure to use the optimized sftp upload method
|
// save data, make sure to use the optimized sftp upload method
|
||||||
wbytes, err := f.ReadFrom(rd)
|
wbytes, err := f.ReadFrom(rd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
|
err = r.checkNoSpace(dirname, rd.Length(), err)
|
||||||
return errors.Wrap(err, "Write")
|
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)
|
debug.Log("sftp: StatVFS returned %v", err)
|
||||||
return origErr
|
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")
|
err := errors.New("sftp: no space left on device")
|
||||||
return backoff.Permanent(err)
|
return backoff.Permanent(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user