mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 10:56:10 +01:00 
			
		
		
		
	Refactor the usage of batch catfile (#31754)
When opening a repository, it will call `ensureValidRepository` and also `CatFileBatch`. But sometimes these will not be used until repository closed. So it's a waste of CPU to invoke 3 times git command for every open repository. This PR removed all of these from `OpenRepository` but only kept checking whether the folder exists. When a batch is necessary, the necessary functions will be invoked.
This commit is contained in:
		| @@ -124,7 +124,10 @@ func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string, | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	batchStdinWriter, batchReader, cancel := commit.repo.CatFileBatch(ctx) | ||||
| 	batchStdinWriter, batchReader, cancel, err := commit.repo.CatFileBatch(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	defer cancel() | ||||
|  | ||||
| 	commitsMap := map[string]*Commit{} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user