forked from TrueCloudLab/rclone
vendor: update all dependencies
This commit is contained in:
parent
17b4058ee9
commit
abb9f89f65
443 changed files with 32118 additions and 18237 deletions
66
vendor/github.com/pkg/sftp/request-example.go
generated
vendored
66
vendor/github.com/pkg/sftp/request-example.go
generated
vendored
|
@ -11,6 +11,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
@ -90,18 +91,51 @@ func (fs *root) Filecmd(r *Request) error {
|
|||
file.name = r.Target
|
||||
fs.files[r.Target] = file
|
||||
delete(fs.files, r.Filepath)
|
||||
|
||||
if file.IsDir() {
|
||||
for path, file := range fs.files {
|
||||
if strings.HasPrefix(path, r.Filepath+"/") {
|
||||
file.name = r.Target + path[len(r.Filepath):]
|
||||
fs.files[r.Target+path[len(r.Filepath):]] = file
|
||||
delete(fs.files, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
case "Rmdir", "Remove":
|
||||
_, err := fs.fetch(filepath.Dir(r.Filepath))
|
||||
file, err := fs.fetch(filepath.Dir(r.Filepath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if file.IsDir() {
|
||||
for path := range fs.files {
|
||||
if strings.HasPrefix(path, r.Filepath+"/") {
|
||||
return &os.PathError{
|
||||
Op: "remove",
|
||||
Path: r.Filepath + "/",
|
||||
Err: fmt.Errorf("directory is not empty"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete(fs.files, r.Filepath)
|
||||
|
||||
case "Mkdir":
|
||||
_, err := fs.fetch(filepath.Dir(r.Filepath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fs.files[r.Filepath] = newMemFile(r.Filepath, true)
|
||||
case "Link":
|
||||
file, err := fs.fetch(r.Filepath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if file.IsDir() {
|
||||
return fmt.Errorf("hard link not allowed for directory")
|
||||
}
|
||||
fs.files[r.Target] = file
|
||||
case "Symlink":
|
||||
_, err := fs.fetch(r.Filepath)
|
||||
if err != nil {
|
||||
|
@ -147,15 +181,15 @@ func (fs *root) Filelist(r *Request) (ListerAt, error) {
|
|||
if !file.IsDir() {
|
||||
return nil, syscall.ENOTDIR
|
||||
}
|
||||
ordered_names := []string{}
|
||||
for fn, _ := range fs.files {
|
||||
orderedNames := []string{}
|
||||
for fn := range fs.files {
|
||||
if filepath.Dir(fn) == r.Filepath {
|
||||
ordered_names = append(ordered_names, fn)
|
||||
orderedNames = append(orderedNames, fn)
|
||||
}
|
||||
}
|
||||
sort.Strings(ordered_names)
|
||||
list := make([]os.FileInfo, len(ordered_names))
|
||||
for i, fn := range ordered_names {
|
||||
sort.Strings(orderedNames)
|
||||
list := make([]os.FileInfo, len(orderedNames))
|
||||
for i, fn := range orderedNames {
|
||||
list[i] = fs.files[fn]
|
||||
}
|
||||
return listerat(list), nil
|
||||
|
@ -199,13 +233,15 @@ func (fs *root) fetch(path string) (*memFile, error) {
|
|||
|
||||
// Implements os.FileInfo, Reader and Writer interfaces.
|
||||
// These are the 3 interfaces necessary for the Handlers.
|
||||
// Implements the optional interface TransferError.
|
||||
type memFile struct {
|
||||
name string
|
||||
modtime time.Time
|
||||
symlink string
|
||||
isdir bool
|
||||
content []byte
|
||||
contentLock sync.RWMutex
|
||||
name string
|
||||
modtime time.Time
|
||||
symlink string
|
||||
isdir bool
|
||||
content []byte
|
||||
transferError error
|
||||
contentLock sync.RWMutex
|
||||
}
|
||||
|
||||
// factory to make sure modtime is set
|
||||
|
@ -265,3 +301,7 @@ func (f *memFile) WriteAt(p []byte, off int64) (int, error) {
|
|||
copy(f.content[off:], p)
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (f *memFile) TransferError(err error) {
|
||||
f.transferError = err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue