mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-08 18:04:14 +01:00
Merge pull request 'feat: add optional storage init to doctor commands' (#3034) from viceice/forgejo:feat/doctor/add-init-storage-option into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3034 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
691bb9d171
1 changed files with 11 additions and 0 deletions
|
@ -14,6 +14,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check represents a Doctor check
|
// Check represents a Doctor check
|
||||||
|
@ -25,6 +26,7 @@ type Check struct {
|
||||||
AbortIfFailed bool
|
AbortIfFailed bool
|
||||||
SkipDatabaseInitialization bool
|
SkipDatabaseInitialization bool
|
||||||
Priority int
|
Priority int
|
||||||
|
InitStorage bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func initDBSkipLogger(ctx context.Context) error {
|
func initDBSkipLogger(ctx context.Context) error {
|
||||||
|
@ -84,6 +86,7 @@ func RunChecks(ctx context.Context, colorize, autofix bool, checks []*Check) err
|
||||||
logger := log.BaseLoggerToGeneralLogger(&doctorCheckLogger{colorize: colorize})
|
logger := log.BaseLoggerToGeneralLogger(&doctorCheckLogger{colorize: colorize})
|
||||||
loggerStep := log.BaseLoggerToGeneralLogger(&doctorCheckStepLogger{colorize: colorize})
|
loggerStep := log.BaseLoggerToGeneralLogger(&doctorCheckStepLogger{colorize: colorize})
|
||||||
dbIsInit := false
|
dbIsInit := false
|
||||||
|
storageIsInit := false
|
||||||
for i, check := range checks {
|
for i, check := range checks {
|
||||||
if !dbIsInit && !check.SkipDatabaseInitialization {
|
if !dbIsInit && !check.SkipDatabaseInitialization {
|
||||||
// Only open database after the most basic configuration check
|
// Only open database after the most basic configuration check
|
||||||
|
@ -94,6 +97,14 @@ func RunChecks(ctx context.Context, colorize, autofix bool, checks []*Check) err
|
||||||
}
|
}
|
||||||
dbIsInit = true
|
dbIsInit = true
|
||||||
}
|
}
|
||||||
|
if !storageIsInit && check.InitStorage {
|
||||||
|
if err := storage.Init(); err != nil {
|
||||||
|
logger.Error("Error whilst initializing the storage: %v", err)
|
||||||
|
logger.Error("Check if you are using the right config file. You can use a --config directive to specify one.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
storageIsInit = true
|
||||||
|
}
|
||||||
logger.Info("\n[%d] %s", i+1, check.Title)
|
logger.Info("\n[%d] %s", i+1, check.Title)
|
||||||
if err := check.Run(ctx, loggerStep, autofix); err != nil {
|
if err := check.Run(ctx, loggerStep, autofix); err != nil {
|
||||||
if check.AbortIfFailed {
|
if check.AbortIfFailed {
|
||||||
|
|
Loading…
Reference in a new issue