]> source.dussan.org Git - gitea.git/commitdiff
Fix missing discard in repo_language_stats (#16030)
authorzeripath <art27@cantab.net>
Wed, 16 Jun 2021 22:16:47 +0000 (23:16 +0100)
committerGitHub <noreply@github.com>
Wed, 16 Jun 2021 22:16:47 +0000 (18:16 -0400)
Set the missing discard(1) in repo_language_stats.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
modules/git/repo_language_stats_nogogit.go

index 0130d0a3008717cd2945aeb759b1f43198ac5841..abbf5e943ba43570cac843ad9fff7372c3fa0207 100644 (file)
@@ -25,11 +25,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
        defer cancel()
 
        writeID := func(id string) error {
-               _, err := batchStdinWriter.Write([]byte(id))
-               if err != nil {
-                       return err
-               }
-               _, err = batchStdinWriter.Write([]byte{'\n'})
+               _, err := batchStdinWriter.Write([]byte(id + "\n"))
                return err
        }
 
@@ -85,10 +81,10 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
                        }
 
                        sizeToRead := size
-                       discard := int64(0)
+                       discard := int64(1)
                        if size > fileSizeLimit {
                                sizeToRead = fileSizeLimit
-                               discard = size - fileSizeLimit
+                               discard = size - fileSizeLimit + 1
                        }
 
                        _, err = contentBuf.ReadFrom(io.LimitReader(batchReader, sizeToRead))