sftpfs: fix stat info

This commit is contained in:
Nicola Murino 2021-01-23 09:42:49 +01:00
parent 2b9ba1d520
commit 0caeb68680
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -147,7 +147,11 @@ func (fs *SFTPFs) Stat(name string) (os.FileInfo, error) {
if err := fs.checkConnection(); err != nil {
return nil, err
}
return fs.sftpClient.Stat(name)
info, err := fs.sftpClient.Stat(name)
if err != nil {
return nil, err
}
return NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false), nil
}
// Lstat returns a FileInfo describing the named file
@ -155,7 +159,11 @@ func (fs *SFTPFs) Lstat(name string) (os.FileInfo, error) {
if err := fs.checkConnection(); err != nil {
return nil, err
}
return fs.sftpClient.Lstat(name)
info, err := fs.sftpClient.Lstat(name)
if err != nil {
return nil, err
}
return NewFileInfo(info.Name(), info.IsDir(), info.Size(), info.ModTime(), false), nil
}
// Open opens the named file for reading
@ -260,7 +268,14 @@ func (fs *SFTPFs) ReadDir(dirname string) ([]os.FileInfo, error) {
if err := fs.checkConnection(); err != nil {
return nil, err
}
return fs.sftpClient.ReadDir(dirname)
entries, err := fs.sftpClient.ReadDir(dirname)
if err != nil {
return nil, err
}
for idx, entry := range entries {
entries[idx] = NewFileInfo(entry.Name(), entry.IsDir(), entry.Size(), entry.ModTime(), false)
}
return entries, nil
}
// IsUploadResumeSupported returns true if upload resume is supported.