diff options
author | Michael Kriese <michael.kriese@visualon.de> | 2024-04-08 22:59:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 20:59:09 +0000 |
commit | ff7aab44032cbb22cb6696a1939d1f619621f067 (patch) | |
tree | eb7f8a5ba9b20efb69f802e5439c6d9c456491c9 | |
parent | d872ce006c0400edb10a05f7555f9b08070442e3 (diff) | |
download | gitea-ff7aab44032cbb22cb6696a1939d1f619621f067.tar.gz gitea-ff7aab44032cbb22cb6696a1939d1f619621f067.zip |
Add optional doctor storage init (#30330)
Add optional storage init to doctor
-rw-r--r-- | services/doctor/doctor.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/services/doctor/doctor.go b/services/doctor/doctor.go index 559f8e06da..a4eb5e16b9 100644 --- a/services/doctor/doctor.go +++ b/services/doctor/doctor.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/storage" ) // Check represents a Doctor check @@ -25,6 +26,7 @@ type Check struct { AbortIfFailed bool SkipDatabaseInitialization bool Priority int + InitStorage bool } 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}) loggerStep := log.BaseLoggerToGeneralLogger(&doctorCheckStepLogger{colorize: colorize}) dbIsInit := false + storageIsInit := false for i, check := range checks { if !dbIsInit && !check.SkipDatabaseInitialization { // 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 } + 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) if err := check.Run(ctx, loggerStep, autofix); err != nil { if check.AbortIfFailed { |