mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	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>
This commit is contained in:
		| @@ -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() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user