mirror of
https://codeberg.org/forgejo-aneksajo/forgejo-aneksajo.git
synced 2025-04-21 05:36:43 +02:00
Pre-populate the git-annex UUID cache at startup (#59)
This eliminates the wait time for the first p2phttp connection since server startup at the cost of adding that time to the startup itself. Reviewed-on: https://codeberg.org/forgejo-aneksajo/forgejo-aneksajo/pulls/59 Co-authored-by: Matthias Riße <m.risse@fz-juelich.de> Co-committed-by: Matthias Riße <m.risse@fz-juelich.de>
This commit is contained in:
parent
b0a9f56508
commit
1fc2fcd438
2 changed files with 12 additions and 0 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
|
@ -100,6 +101,14 @@ var (
|
|||
repoPath2uuidCache = make(map[string]string)
|
||||
)
|
||||
|
||||
func Init() error {
|
||||
if !setting.Annex.Enabled {
|
||||
return nil
|
||||
}
|
||||
log.Info("Populating the git-annex UUID cache with existing repositories")
|
||||
return updateUUID2RepoPathCache()
|
||||
}
|
||||
|
||||
func updateUUID2RepoPathCache() error {
|
||||
return filepath.WalkDir(setting.RepoRootPath, func(path string, d fs.DirEntry, err error) error {
|
||||
if err == nil && repoConfigFileRe.MatchString(path) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
authmodel "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/modules/annex"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/eventsource"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
|
@ -167,6 +168,8 @@ func InitWebInstalled(ctx context.Context) {
|
|||
|
||||
actions_service.Init()
|
||||
|
||||
mustInit(annex.Init)
|
||||
|
||||
// Finally start up the cron
|
||||
cron.NewContext(ctx)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue