From f22ec2275f0495a0ba6cf3ed7bc0249d81d225a5 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sun, 10 Nov 2024 20:58:22 +0100 Subject: [PATCH] fix new lint warnings Signed-off-by: Nicola Murino --- internal/common/eventmanager.go | 8 ++++---- internal/sftpd/server.go | 4 ++-- internal/util/errors.go | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/common/eventmanager.go b/internal/common/eventmanager.go index 89c66bcd..d581760c 100644 --- a/internal/common/eventmanager.go +++ b/internal/common/eventmanager.go @@ -1790,7 +1790,7 @@ func executeRenameFsActionForUser(renames []dataprovider.RenameConfig, replacer return nil } -func executeCopyFsActionForUser(copy []dataprovider.KeyValue, replacer *strings.Replacer, +func executeCopyFsActionForUser(keyVals []dataprovider.KeyValue, replacer *strings.Replacer, user dataprovider.User, ) error { user, err := getUserForEventAction(user) @@ -1804,7 +1804,7 @@ func executeCopyFsActionForUser(copy []dataprovider.KeyValue, replacer *strings. return fmt.Errorf("copy error, unable to check root fs for user %q: %w", user.Username, err) } conn := NewBaseConnection(connectionID, protocolEventAction, "", "", user) - for _, item := range copy { + for _, item := range keyVals { source := util.CleanPath(replaceWithReplacer(item.Key, replacer)) target := util.CleanPath(replaceWithReplacer(item.Value, replacer)) if strings.HasSuffix(item.Key, "/") { @@ -1878,7 +1878,7 @@ func executeRenameFsRuleAction(renames []dataprovider.RenameConfig, replacer *st return nil } -func executeCopyFsRuleAction(copy []dataprovider.KeyValue, replacer *strings.Replacer, +func executeCopyFsRuleAction(keyVals []dataprovider.KeyValue, replacer *strings.Replacer, conditions dataprovider.ConditionOptions, params *EventParams, ) error { users, err := params.getUsers() @@ -1897,7 +1897,7 @@ func executeCopyFsRuleAction(copy []dataprovider.KeyValue, replacer *strings.Rep } } executed++ - if err = executeCopyFsActionForUser(copy, replacer, user); err != nil { + if err = executeCopyFsActionForUser(keyVals, replacer, user); err != nil { failures = append(failures, user.Username) params.AddError(err) } diff --git a/internal/sftpd/server.go b/internal/sftpd/server.go index 1e347421..5370bbb6 100644 --- a/internal/sftpd/server.go +++ b/internal/sftpd/server.go @@ -400,8 +400,8 @@ func (c *Configuration) serve(listener net.Listener, serverConfig *ssh.ServerCon } else { tempDelay *= 2 } - if max := 1 * time.Second; tempDelay > max { - tempDelay = max + if maxDelay := 1 * time.Second; tempDelay > maxDelay { + tempDelay = maxDelay } logger.Warn(logSender, "", "accept error: %v; retrying in %v", err, tempDelay) time.Sleep(tempDelay) diff --git a/internal/util/errors.go b/internal/util/errors.go index c2bdfbce..79e54265 100644 --- a/internal/util/errors.go +++ b/internal/util/errors.go @@ -59,9 +59,9 @@ func (e *ValidationError) Is(target error) bool { } // NewValidationError returns a validation errors -func NewValidationError(error string) *ValidationError { +func NewValidationError(errorString string) *ValidationError { return &ValidationError{ - err: error, + err: errorString, } } @@ -81,9 +81,9 @@ func (e *RecordNotFoundError) Is(target error) bool { } // NewRecordNotFoundError returns a not found error -func NewRecordNotFoundError(error string) *RecordNotFoundError { +func NewRecordNotFoundError(errorString string) *RecordNotFoundError { return &RecordNotFoundError{ - err: error, + err: errorString, } } @@ -106,9 +106,9 @@ func (e *MethodDisabledError) Is(target error) bool { } // NewMethodDisabledError returns a method disabled error -func NewMethodDisabledError(error string) *MethodDisabledError { +func NewMethodDisabledError(errorString string) *MethodDisabledError { return &MethodDisabledError{ - err: error, + err: errorString, } } @@ -128,8 +128,8 @@ func (e *GenericError) Is(target error) bool { } // NewGenericError returns a generic error -func NewGenericError(error string) *GenericError { +func NewGenericError(errorString string) *GenericError { return &GenericError{ - err: error, + err: errorString, } }