Skip to content

Commit 2c263b2

Browse files
author
Earl Warren
committed
Merge pull request '[v7.0/forgejo] feat: add optional storage init to doctor commands' (go-gitea#3035) from bp-v7.0/forgejo-e226a27 into v7.0/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3035 Reviewed-by: Michael Kriese <[email protected]>
2 parents 2bf3723 + 5b7d454 commit 2c263b2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

services/doctor/doctor.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/modules/git"
1515
"code.gitea.io/gitea/modules/log"
1616
"code.gitea.io/gitea/modules/setting"
17+
"code.gitea.io/gitea/modules/storage"
1718
)
1819

1920
// Check represents a Doctor check
@@ -25,6 +26,7 @@ type Check struct {
2526
AbortIfFailed bool
2627
SkipDatabaseInitialization bool
2728
Priority int
29+
InitStorage bool
2830
}
2931

3032
func initDBSkipLogger(ctx context.Context) error {
@@ -84,6 +86,7 @@ func RunChecks(ctx context.Context, colorize, autofix bool, checks []*Check) err
8486
logger := log.BaseLoggerToGeneralLogger(&doctorCheckLogger{colorize: colorize})
8587
loggerStep := log.BaseLoggerToGeneralLogger(&doctorCheckStepLogger{colorize: colorize})
8688
dbIsInit := false
89+
storageIsInit := false
8790
for i, check := range checks {
8891
if !dbIsInit && !check.SkipDatabaseInitialization {
8992
// Only open database after the most basic configuration check
@@ -94,6 +97,14 @@ func RunChecks(ctx context.Context, colorize, autofix bool, checks []*Check) err
9497
}
9598
dbIsInit = true
9699
}
100+
if !storageIsInit && check.InitStorage {
101+
if err := storage.Init(); err != nil {
102+
logger.Error("Error whilst initializing the storage: %v", err)
103+
logger.Error("Check if you are using the right config file. You can use a --config directive to specify one.")
104+
return nil
105+
}
106+
storageIsInit = true
107+
}
97108
logger.Info("\n[%d] %s", i+1, check.Title)
98109
if err := check.Run(ctx, loggerStep, autofix); err != nil {
99110
if check.AbortIfFailed {

0 commit comments

Comments
 (0)