diff --git a/models/asymkey/ssh_key_authorized_keys.go b/models/asymkey/ssh_key_authorized_keys.go index f0a3a77eaff04..7ef4f3545d54c 100644 --- a/models/asymkey/ssh_key_authorized_keys.go +++ b/models/asymkey/ssh_key_authorized_keys.go @@ -206,6 +206,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/models/asymkey/ssh_key_authorized_principals.go b/models/asymkey/ssh_key_authorized_principals.go index 592196c255ae7..3242b54ae4880 100644 --- a/models/asymkey/ssh_key_authorized_principals.go +++ b/models/asymkey/ssh_key_authorized_principals.go @@ -128,6 +128,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/modules/doctor/authorizedkeys.go b/modules/doctor/authorizedkeys.go index 050a4e79742f0..43740af3db233 100644 --- a/modules/doctor/authorizedkeys.go +++ b/modules/doctor/authorizedkeys.go @@ -50,6 +50,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 diff --git a/modules/git/commit.go b/modules/git/commit.go index 4ff8f6148f741..933a6fa660b27 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -9,6 +9,7 @@ import ( "bytes" "context" "errors" + "fmt" "io" "os/exec" "strconv" @@ -391,6 +392,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 12458e954ade9..75baf980136c0 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" @@ -98,6 +99,10 @@ func (Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.Wri } return tmpBlock.Flush() } + err = scan.Err() + if err != nil { + return fmt.Errorf("scan: %w", err) + } rd, err := csv.CreateReaderAndDetermineDelimiter(ctx, bytes.NewReader(rawBytes)) if err != nil { diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index e778104a0fa9c..f953feedcd6ce 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -977,5 +977,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 }