summaryrefslogtreecommitdiffstats
path: root/modules/git/repo_language_stats_nogogit.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-11-30 20:06:32 +0000
committerGitHub <noreply@github.com>2021-11-30 20:06:32 +0000
commit01087e9eef21ff5ea1cebbb1e84933954671fdf2 (patch)
treeae618785a3bd46e012096683e2fd2309f87c571d /modules/git/repo_language_stats_nogogit.go
parentd894c90b703ce215e2319ae2e2bf95989f77805d (diff)
downloadgitea-01087e9eef21ff5ea1cebbb1e84933954671fdf2.tar.gz
gitea-01087e9eef21ff5ea1cebbb1e84933954671fdf2.zip
Make Requests Processes and create process hierarchy. Associate OpenRepository with context. (#17125)
This PR registers requests with the process manager and manages hierarchy within the processes. Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/repo_language_stats_nogogit.go')
-rw-r--r--modules/git/repo_language_stats_nogogit.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/git/repo_language_stats_nogogit.go b/modules/git/repo_language_stats_nogogit.go
index 4fda7ab627..0b21bf6344 100644
--- a/modules/git/repo_language_stats_nogogit.go
+++ b/modules/git/repo_language_stats_nogogit.go
@@ -25,7 +25,7 @@ import (
func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, error) {
// We will feed the commit IDs in order into cat-file --batch, followed by blobs as necessary.
// so let's create a batch stdin and stdout
- batchStdinWriter, batchReader, cancel := repo.CatFileBatch()
+ batchStdinWriter, batchReader, cancel := repo.CatFileBatch(repo.Ctx)
defer cancel()
writeID := func(id string) error {
@@ -76,7 +76,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
IndexFile: indexFilename,
WorkTree: worktree,
}
- ctx, cancel := context.WithCancel(DefaultContext)
+ ctx, cancel := context.WithCancel(repo.Ctx)
if err := checker.Init(ctx); err != nil {
log.Error("Unable to open checker for %s. Error: %v", commitID, err)
} else {
@@ -96,6 +96,12 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
var content []byte
sizes := make(map[string]int64)
for _, f := range entries {
+ select {
+ case <-repo.Ctx.Done():
+ return sizes, repo.Ctx.Err()
+ default:
+ }
+
contentBuf.Reset()
content = contentBuf.Bytes()