add dot and dot dot directories to sftp/ftp file listing

This commit is contained in:
Nicola Murino
2021-07-31 09:42:23 +02:00
parent f778e47d22
commit a26962f367
9 changed files with 71 additions and 22 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/drakkan/sftpgo/v2/common"
"github.com/drakkan/sftpgo/v2/dataprovider"
"github.com/drakkan/sftpgo/v2/logger"
"github.com/drakkan/sftpgo/v2/util"
"github.com/drakkan/sftpgo/v2/vfs"
)
@@ -271,7 +272,15 @@ func (c *Connection) Symlink(oldname, newname string) error {
func (c *Connection) ReadDir(name string) ([]os.FileInfo, error) {
c.UpdateLastActivity()
return c.ListDir(name)
files, err := c.ListDir(name)
if err != nil {
return files, err
}
if name != "/" {
files = util.PrependFileInfo(files, vfs.NewFileInfo("..", true, 0, time.Now(), false))
}
files = util.PrependFileInfo(files, vfs.NewFileInfo(".", true, 0, time.Now(), false))
return files, nil
}
// GetHandle implements ClientDriverExtentionFileTransfer