Skip to content

Commit df41181

Browse files
Zettat123lunny
andauthoredMar 23, 2023
Check LFS/Packages settings in dump and doctor command (#23631)
Close #23622 As described in the issue, disabling the LFS/Package settings will cause errors when running `gitea dump` or `gitea doctor`. We need to check the settings and the related operations should be skipped if the settings are disabled. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent 9be90a5 commit df41181

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
 

‎cmd/dump.go

+4
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ func runDump(ctx *cli.Context) error {
250250

251251
if ctx.IsSet("skip-lfs-data") && ctx.Bool("skip-lfs-data") {
252252
log.Info("Skip dumping LFS data")
253+
} else if !setting.LFS.StartServer {
254+
log.Info("LFS isn't enabled. Skip dumping LFS data")
253255
} else if err := storage.LFS.IterateObjects("", func(objPath string, object storage.Object) error {
254256
info, err := object.Stat()
255257
if err != nil {
@@ -364,6 +366,8 @@ func runDump(ctx *cli.Context) error {
364366

365367
if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
366368
log.Info("Skip dumping package data")
369+
} else if !setting.Packages.Enabled {
370+
log.Info("Packages isn't enabled. Skip dumping package data")
367371
} else if err := storage.Packages.IterateObjects("", func(objPath string, object storage.Object) error {
368372
info, err := object.Stat()
369373
if err != nil {

‎modules/doctor/storage.go

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/base"
1717
"code.gitea.io/gitea/modules/log"
1818
packages_module "code.gitea.io/gitea/modules/packages"
19+
"code.gitea.io/gitea/modules/setting"
1920
"code.gitea.io/gitea/modules/storage"
2021
"code.gitea.io/gitea/modules/util"
2122
)
@@ -111,6 +112,10 @@ func checkStorage(opts *checkStorageOptions) func(ctx context.Context, logger lo
111112
}
112113

113114
if opts.LFS || opts.All {
115+
if !setting.LFS.StartServer {
116+
logger.Info("LFS isn't enabled (skipped)")
117+
return nil
118+
}
114119
if err := commonCheckStorage(ctx, logger, autofix,
115120
&commonStorageCheckOptions{
116121
storer: storage.LFS,
@@ -173,6 +178,10 @@ func checkStorage(opts *checkStorageOptions) func(ctx context.Context, logger lo
173178
}
174179

175180
if opts.Packages || opts.All {
181+
if !setting.Packages.Enabled {
182+
logger.Info("Packages isn't enabled (skipped)")
183+
return nil
184+
}
176185
if err := commonCheckStorage(ctx, logger, autofix,
177186
&commonStorageCheckOptions{
178187
storer: storage.Packages,

0 commit comments

Comments
 (0)
Please sign in to comment.