mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-27 01:18:27 +00: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:
		| @@ -46,7 +46,10 @@ func FindLFSFile(repo *git.Repository, objectID git.ObjectID) ([]*LFSResult, err | ||||
|  | ||||
| 	// Next feed the commits in order into cat-file --batch, followed by their trees and sub trees as necessary. | ||||
| 	// so let's create a batch stdin and stdout | ||||
| 	batchStdinWriter, batchReader, cancel := repo.CatFileBatch(repo.Ctx) | ||||
| 	batchStdinWriter, batchReader, cancel, err := repo.CatFileBatch(repo.Ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	defer cancel() | ||||
|  | ||||
| 	// We'll use a scanner for the revList because it's simpler than a bufio.Reader | ||||
|   | ||||
		Reference in New Issue
	
	Block a user