mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
fix the error message for errors that occur during file transfers
we should special case path errors and replace the fs path with the virtual path. Thanks to @nezzzumi for reporting this issue Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -1739,9 +1740,10 @@ func (c *BaseConnection) GetGenericError(err error) error {
|
||||
return fmt.Errorf("%w: %v", sftp.ErrSSHFxFailure, err.Error())
|
||||
}
|
||||
if err != nil {
|
||||
if e, ok := err.(*os.PathError); ok {
|
||||
c.Log(logger.LevelError, "generic path error: %+v", e)
|
||||
return fmt.Errorf("%w: %v %v", sftp.ErrSSHFxFailure, e.Op, e.Err.Error())
|
||||
var pathError *fs.PathError
|
||||
if errors.As(err, &pathError) {
|
||||
c.Log(logger.LevelError, "generic path error: %+v", pathError)
|
||||
return fmt.Errorf("%w: %v %v", sftp.ErrSSHFxFailure, pathError.Op, pathError.Err.Error())
|
||||
}
|
||||
c.Log(logger.LevelError, "generic error: %+v", err)
|
||||
return fmt.Errorf("%w: %v", sftp.ErrSSHFxFailure, ErrGenericFailure.Error())
|
||||
|
||||
Reference in New Issue
Block a user