diff --git a/models/asymkey/ssh_key_authorized_keys.go b/models/asymkey/ssh_key_authorized_keys.go index 2b15450c9..8c3e0aa81 100644 --- a/models/asymkey/ssh_key_authorized_keys.go +++ b/models/asymkey/ssh_key_authorized_keys.go @@ -211,6 +211,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 f3017c308..9e6cc3685 100644 --- a/models/asymkey/ssh_key_authorized_principals.go +++ b/models/asymkey/ssh_key_authorized_principals.go @@ -133,6 +133,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/git/commit.go b/modules/git/commit.go index c30f1e35e..47237d2d5 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -9,6 +9,7 @@ import ( "bytes" "context" "errors" + "fmt" "io" "os/exec" "strconv" @@ -390,6 +391,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 41f94e24f..ce8294687 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 570c4f470..50bb91844 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 b0570f97c..bf42b77b6 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/doctor/authorizedkeys.go b/services/doctor/authorizedkeys.go index 050a4e797..43740af3d 100644 --- a/services/doctor/authorizedkeys.go +++ b/services/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