forked from TrueCloudLab/restic
Update vendored library github.com/pkg/sftp
This commit is contained in:
parent
d9ba9279e0
commit
19035e977b
27 changed files with 494 additions and 240 deletions
21
vendor/github.com/pkg/sftp/example_test.go
generated
vendored
21
vendor/github.com/pkg/sftp/example_test.go
generated
vendored
|
@ -1,7 +1,9 @@
|
|||
package sftp_test
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -107,13 +109,13 @@ func ExampleClient_Mkdir_parents() {
|
|||
sshFxFailure := uint32(4)
|
||||
mkdirParents := func(client *sftp.Client, dir string) (err error) {
|
||||
var parents string
|
||||
|
||||
|
||||
if path.IsAbs(dir) {
|
||||
// Otherwise, an absolute path given below would be turned in to a relative one
|
||||
// by splitting on "/"
|
||||
parents = "/"
|
||||
}
|
||||
|
||||
|
||||
for _, name := range strings.Split(dir, "/") {
|
||||
if name == "" {
|
||||
// Paths with double-/ in them should just move along
|
||||
|
@ -145,3 +147,18 @@ func ExampleClient_Mkdir_parents() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleFile_ReadFrom_bufio() {
|
||||
// Using Bufio to buffer writes going to an sftp.File won't buffer as it
|
||||
// skips buffering if the underlying writer support ReadFrom. The
|
||||
// workaround is to wrap your writer in a struct that only implements
|
||||
// io.Writer.
|
||||
//
|
||||
// For background see github.com/pkg/sftp/issues/125
|
||||
|
||||
var data_source io.Reader
|
||||
var f *sftp.File
|
||||
type writerOnly struct{ io.Writer }
|
||||
bw := bufio.NewWriter(writerOnly{f}) // no ReadFrom()
|
||||
bw.ReadFrom(data_source)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue