Skip to content

Commit ff7aab4

Browse files
authored
Add optional doctor storage init (#30330)
Add optional storage init to doctor
1 parent d872ce0 commit ff7aab4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

services/doctor/doctor.go

+11
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)