Skip to content

Commit

Permalink
CB/revert: Revert "Sync git hooks when config file path changed (go-g…
Browse files Browse the repository at this point in the history
…itea#21619) (go-gitea#21625)"

This reverts commit 7a2daae.

On initial run, this printed
2022/11/07 02:57:24 routers/init.go:90:syncAppConfForGit() [I] CustomConf changed from '' to '/etc/gitea/conf/app.ini'
But for large instances, it's a terrible idea to attempt writing
something to every Git repository *before* starting Gitea.
  • Loading branch information
fnetX committed Nov 7, 2022
1 parent d1ef071 commit 26b92e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
3 changes: 1 addition & 2 deletions modules/appstate/item_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ package appstate

// RuntimeState contains app state for runtime, and we can save remote version for update checker here in future
type RuntimeState struct {
LastAppPath string `json:"last_app_path"`
LastCustomConf string `json:"last_custom_conf"`
LastAppPath string `json:"last_app_path"`
}

// Name returns the item name
Expand Down
16 changes: 3 additions & 13 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,21 @@ func InitGitServices() {
mustInit(repo_service.Init)
}

func syncAppConfForGit(ctx context.Context) error {
func syncAppPathForGit(ctx context.Context) error {
runtimeState := new(appstate.RuntimeState)
if err := appstate.AppState.Get(runtimeState); err != nil {
return err
}

updated := false
if runtimeState.LastAppPath != setting.AppPath {
log.Info("AppPath changed from '%s' to '%s'", runtimeState.LastAppPath, setting.AppPath)
runtimeState.LastAppPath = setting.AppPath
updated = true
}
if runtimeState.LastCustomConf != setting.CustomConf {
log.Info("CustomConf changed from '%s' to '%s'", runtimeState.LastCustomConf, setting.CustomConf)
runtimeState.LastCustomConf = setting.CustomConf
updated = true
}

if updated {
log.Info("re-sync repository hooks ...")
mustInitCtx(ctx, repo_service.SyncRepositoryHooks)

log.Info("re-write ssh public keys ...")
mustInit(asymkey_model.RewriteAllPublicKeys)

runtimeState.LastAppPath = setting.AppPath
return appstate.AppState.Set(runtimeState)
}
return nil
Expand Down Expand Up @@ -163,7 +153,7 @@ func GlobalInitInstalled(ctx context.Context) {
mustInit(repo_migrations.Init)
eventsource.GetManager().Init()

mustInitCtx(ctx, syncAppConfForGit)
mustInitCtx(ctx, syncAppPathForGit)

mustInit(ssh.Init)

Expand Down

0 comments on commit 26b92e3

Please sign in to comment.