mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +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:
@@ -16,6 +16,8 @@ package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"path"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -220,6 +222,10 @@ func (t *BaseTransfer) ConvertError(err error) error {
|
||||
} else if t.Fs.IsPermission(err) {
|
||||
return t.Connection.GetPermissionDeniedError()
|
||||
}
|
||||
var pathError *fs.PathError
|
||||
if errors.As(err, &pathError) {
|
||||
return fmt.Errorf("%s %s: %s", pathError.Op, t.GetVirtualPath(), pathError.Err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user