diff --git a/internal/common/transfer.go b/internal/common/transfer.go index 9bf354fb..f4e78e30 100644 --- a/internal/common/transfer.go +++ b/internal/common/transfer.go @@ -352,6 +352,9 @@ func (t *BaseTransfer) checkUploadOutsideHomeDir(err error) int { if err == nil { return 0 } + if t.ErrTransfer == nil { + t.ErrTransfer = err + } if Config.TempPath == "" { return 0 } @@ -410,7 +413,8 @@ func (t *BaseTransfer) Close() error { var uploadFileSize int64 if t.transferType == TransferDownload { logger.TransferLog(downloadLogSender, t.fsPath, elapsed, t.BytesSent.Load(), t.Connection.User.Username, - t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode) + t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode, + t.ErrTransfer) ExecuteActionNotification(t.Connection, operationDownload, t.fsPath, t.requestPath, "", "", "", //nolint:errcheck t.BytesSent.Load(), t.ErrTransfer, elapsed, t.metadata) } else { @@ -431,7 +435,8 @@ func (t *BaseTransfer) Close() error { t.updateQuota(numFiles, uploadFileSize) t.updateTimes() logger.TransferLog(uploadLogSender, t.fsPath, elapsed, t.BytesReceived.Load(), t.Connection.User.Username, - t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode) + t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode, + t.ErrTransfer) } if t.ErrTransfer != nil { t.Connection.Log(logger.LevelError, "transfer error: %v, path: %q", t.ErrTransfer, t.fsPath) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index a5191ee1..48a51065 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -203,7 +203,7 @@ func ErrorToConsole(format string, v ...any) { // TransferLog logs uploads or downloads func TransferLog(operation, path string, elapsed int64, size int64, user, connectionID, protocol, localAddr, - remoteAddr, ftpMode string, + remoteAddr, ftpMode string, err error, ) { ev := logger.Info(). Timestamp(). @@ -219,7 +219,7 @@ func TransferLog(operation, path string, elapsed int64, size int64, user, connec if ftpMode != "" { ev.Str("ftp_mode", ftpMode) } - ev.Send() + ev.AnErr("error", err).Send() } // CommandLog logs an SFTP/SCP/SSH command