sftpd: remove workarounds for directory listing
The underlying issue was fixed in pkg/sftp 1.13.2
This commit is contained in:
parent
bd5191dfc5
commit
7344366ce8
4 changed files with 4 additions and 55 deletions
|
@ -65,5 +65,5 @@ func (fi *FileInfo) SetMode(mode os.FileMode) {
|
|||
|
||||
// Sys provides the underlying data source (can return nil)
|
||||
func (fi *FileInfo) Sys() interface{} {
|
||||
return fi.getFileInfoSys()
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -206,13 +206,7 @@ func (fs *SFTPFs) Stat(name string) (os.FileInfo, error) {
|
|||
if err := fs.checkConnection(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info, err := fs.sftpClient.Stat(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fi := NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false)
|
||||
fi.SetMode(info.Mode())
|
||||
return fi, nil
|
||||
return fs.sftpClient.Stat(name)
|
||||
}
|
||||
|
||||
// Lstat returns a FileInfo describing the named file
|
||||
|
@ -220,13 +214,7 @@ func (fs *SFTPFs) Lstat(name string) (os.FileInfo, error) {
|
|||
if err := fs.checkConnection(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info, err := fs.sftpClient.Lstat(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fi := NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false)
|
||||
fi.SetMode(info.Mode())
|
||||
return fi, nil
|
||||
return fs.sftpClient.Lstat(name)
|
||||
}
|
||||
|
||||
// Open opens the named file for reading
|
||||
|
@ -407,18 +395,7 @@ func (fs *SFTPFs) ReadDir(dirname string) ([]os.FileInfo, error) {
|
|||
if err := fs.checkConnection(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
entries, err := fs.sftpClient.ReadDir(dirname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]os.FileInfo, 0, len(entries))
|
||||
|
||||
for _, entry := range entries {
|
||||
info := NewFileInfo(entry.Name(), entry.IsDir(), entry.Size(), entry.ModTime(), false)
|
||||
info.SetMode(entry.Mode())
|
||||
result = append(result, info)
|
||||
}
|
||||
return result, nil
|
||||
return fs.sftpClient.ReadDir(dirname)
|
||||
}
|
||||
|
||||
// IsUploadResumeSupported returns true if resuming uploads is supported.
|
||||
|
|
|
@ -4,33 +4,10 @@ package vfs
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultUID, defaultGID int
|
||||
)
|
||||
|
||||
func init() {
|
||||
defaultUID = os.Getuid()
|
||||
defaultGID = os.Getuid()
|
||||
if defaultUID < 0 {
|
||||
defaultUID = 65534
|
||||
}
|
||||
if defaultGID < 0 {
|
||||
defaultGID = 65534
|
||||
}
|
||||
}
|
||||
|
||||
func (fi FileInfo) getFileInfoSys() interface{} {
|
||||
return &syscall.Stat_t{
|
||||
Uid: uint32(defaultUID),
|
||||
Gid: uint32(defaultGID)}
|
||||
}
|
||||
|
||||
func isCrossDeviceError(err error) bool {
|
||||
return errors.Is(err, unix.EXDEV)
|
||||
}
|
||||
|
|
|
@ -2,15 +2,10 @@ package vfs
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func (fi FileInfo) getFileInfoSys() interface{} {
|
||||
return syscall.Win32FileAttributeData{}
|
||||
}
|
||||
|
||||
func isCrossDeviceError(err error) bool {
|
||||
return errors.Is(err, windows.ERROR_NOT_SAME_DEVICE)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue