Add support for graceful shutdown

Fixes #1014

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-10-22 11:56:41 +02:00
parent 87045284cc
commit db0e58ae7e
32 changed files with 371 additions and 124 deletions

View File

@@ -496,18 +496,10 @@ func (c *scpCommand) handleDownload(filePath string) error {
}
var err error
fs, err := c.connection.User.GetFilesystemForPath(filePath, c.connection.ID)
fs, p, err := c.connection.GetFsAndResolvedPath(filePath)
if err != nil {
c.connection.Log(logger.LevelError, "error downloading file %#v: %+v", filePath, err)
c.sendErrorMessage(nil, fmt.Errorf("unable to get fs for path %#v", filePath))
return err
}
p, err := fs.ResolvePath(filePath)
if err != nil {
err := fmt.Errorf("invalid file path %#v", filePath)
c.connection.Log(logger.LevelError, "error downloading file: %#v, invalid file path", filePath)
c.sendErrorMessage(fs, err)
c.connection.Log(logger.LevelError, "error downloading file %q: %+v", filePath, err)
c.sendErrorMessage(nil, fmt.Errorf("unable to download file %q: %w", filePath, err))
return err
}