mirror of
https://github.com/octoleo/restic.git
synced 2024-11-29 16:23:59 +00:00
sftp: enforce use of optimized upload method
ReadFrom was already used by Save before, this just ensures that this won't accidentally change in the future.
This commit is contained in:
parent
6b5b29dbee
commit
678e75e1c2
@ -287,8 +287,8 @@ func (r *SFTP) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader
|
||||
return errors.Wrap(err, "OpenFile")
|
||||
}
|
||||
|
||||
// save data
|
||||
_, err = io.Copy(f, rd)
|
||||
// save data, make sure to use the optimized sftp upload method
|
||||
_, err = f.ReadFrom(rd)
|
||||
if err != nil {
|
||||
_ = f.Close()
|
||||
return errors.Wrap(err, "Write")
|
||||
@ -332,6 +332,8 @@ func (r *SFTP) openReader(ctx context.Context, h restic.Handle, length int, offs
|
||||
}
|
||||
|
||||
if length > 0 {
|
||||
// unlimited reads usually use io.Copy which needs WriteTo support at the underlying reader
|
||||
// limited reads are usually combined with io.ReadFull which reads all required bytes into a buffer in one go
|
||||
return backend.LimitReadCloser(f, int64(length)), nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user