gitbase: use only one cache for all repositories #898
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also fix a bug getting the cache size from cli.
Before integrating the use of
go-borgesrepositories were managed byRepositoryPool. When it was created it initialized a git object cache that is used by all the repositories. This cache is also used when using indexes and reading directly from packfiles (cache is retrieved withRepository.Cache(), https://github.com/src-d/gitbase/blob/master/packfiles.go#L239).Now
go-borgestakes care of repository libraries and retrieving go-git repositories from them. To make it work the same we initializego-borgeslibrary with a cache generated ingitbase(command.Server) but I forgot thatRepositoryPoolwas also generating a cache internally and returning it when callingRepository.Cache(). This means that there was two different objects caches, one for repositories opened without indexes and other for reading packfiles when the index was used. The problems are:The change makes
RepositoryPoolget an initialized cache that will be used by all repos (both with and without index).make upgradecommand if applicable.