diff --git a/models/asymkey/ssh_key_authorized_keys.go b/models/asymkey/ssh_key_authorized_keys.go index 9279db20208fb..7621994866e3f 100644 --- a/models/asymkey/ssh_key_authorized_keys.go +++ b/models/asymkey/ssh_key_authorized_keys.go @@ -152,6 +152,10 @@ func RegeneratePublicKeys(ctx context.Context, t io.StringWriter) error { return err } } + err = scanner.Err() + if err != nil { + return fmt.Errorf("scan: %w", err) + } f.Close() } return nil diff --git a/modules/git/commit.go b/modules/git/commit.go index facb632bd9b5e..789a2e8f6927f 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -9,6 +9,7 @@ import ( "bytes" "context" "errors" + "fmt" "io" "os/exec" "strconv" @@ -396,6 +397,10 @@ func (c *Commit) GetSubModules() (*ObjectCache, error) { } } } + err = scanner.Err() + if err != nil { + return nil, fmt.Errorf("scan: %w", err) + } return c.submoduleCache, nil } diff --git a/modules/git/repo_stats.go b/modules/git/repo_stats.go index 41f94e24f99ca..ce82946873e1e 100644 --- a/modules/git/repo_stats.go +++ b/modules/git/repo_stats.go @@ -124,6 +124,10 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) } } } + err = scanner.Err() + if err != nil { + return fmt.Errorf("scan: %w", err) + } a := make([]*CodeActivityAuthor, 0, len(authors)) for _, v := range authors { a = append(a, v) diff --git a/modules/markup/csv/csv.go b/modules/markup/csv/csv.go index 570c4f47041da..50bb918442686 100644 --- a/modules/markup/csv/csv.go +++ b/modules/markup/csv/csv.go @@ -6,6 +6,7 @@ package markup import ( "bufio" "bytes" + "fmt" "html" "io" "regexp" @@ -123,6 +124,10 @@ func (Renderer) fallbackRender(input io.Reader, tmpBlock *bufio.Writer) error { return err } } + err = scan.Err() + if err != nil { + return fmt.Errorf("scan: %w", err) + } _, err = tmpBlock.WriteString("") if err != nil { diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index b0570f97c3b7b..bf42b77b66a4b 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -980,5 +980,9 @@ func getExcerptLines(commit *git.Commit, filePath string, idxLeft, idxRight, chu } diffLines = append(diffLines, diffLine) } + err = scanner.Err() + if err != nil { + return nil, fmt.Errorf("scan: %w", err) + } return diffLines, nil } diff --git a/services/asymkey/ssh_key_authorized_principals.go b/services/asymkey/ssh_key_authorized_principals.go index 9154db7dbb58a..822dd0ffe7a00 100644 --- a/services/asymkey/ssh_key_authorized_principals.go +++ b/services/asymkey/ssh_key_authorized_principals.go @@ -122,6 +122,10 @@ func regeneratePrincipalKeys(ctx context.Context, t io.StringWriter) error { return err } } + err = scanner.Err() + if err != nil { + return fmt.Errorf("scan: %w", err) + } f.Close() } return nil diff --git a/services/doctor/authorizedkeys.go b/services/doctor/authorizedkeys.go index d5a96605b9ca2..bc0266c4bc78b 100644 --- a/services/doctor/authorizedkeys.go +++ b/services/doctor/authorizedkeys.go @@ -51,6 +51,10 @@ func checkAuthorizedKeys(ctx context.Context, logger log.Logger, autofix bool) e } linesInAuthorizedKeys.Add(line) } + err = scanner.Err() + if err != nil { + return fmt.Errorf("scan: %w", err) + } f.Close() // now we regenerate and check if there are any lines missing