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)
|
// Sys provides the underlying data source (can return nil)
|
||||||
func (fi *FileInfo) Sys() interface{} {
|
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 {
|
if err := fs.checkConnection(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
info, err := fs.sftpClient.Stat(name)
|
return 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lstat returns a FileInfo describing the named file
|
// 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 {
|
if err := fs.checkConnection(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
info, err := fs.sftpClient.Lstat(name)
|
return 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open opens the named file for reading
|
// 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 {
|
if err := fs.checkConnection(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
entries, err := fs.sftpClient.ReadDir(dirname)
|
return 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsUploadResumeSupported returns true if resuming uploads is supported.
|
// IsUploadResumeSupported returns true if resuming uploads is supported.
|
||||||
|
|
|
@ -4,33 +4,10 @@ package vfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"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 {
|
func isCrossDeviceError(err error) bool {
|
||||||
return errors.Is(err, unix.EXDEV)
|
return errors.Is(err, unix.EXDEV)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,10 @@ package vfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (fi FileInfo) getFileInfoSys() interface{} {
|
|
||||||
return syscall.Win32FileAttributeData{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func isCrossDeviceError(err error) bool {
|
func isCrossDeviceError(err error) bool {
|
||||||
return errors.Is(err, windows.ERROR_NOT_SAME_DEVICE)
|
return errors.Is(err, windows.ERROR_NOT_SAME_DEVICE)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue