Skip to content

Commit 218e9c8

Browse files
johanvdwlunny
authored andcommitted
dump: Add option to skip LFS/attachment files (go-gitea#15407)
Backport go-gitea#15407 * Add option to skip dumping LFS/attachment files * Fix fmt issues Co-authored-by: Lunny Xiao <[email protected]>
1 parent 211bb91 commit 218e9c8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

cmd/dump.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
129129
Name: "skip-custom-dir",
130130
Usage: "Skip custom directory",
131131
},
132+
cli.BoolFlag{
133+
Name: "skip-lfs-data",
134+
Usage: "Skip LFS data",
135+
},
136+
cli.BoolFlag{
137+
Name: "skip-attachment-data",
138+
Usage: "Skip attachment data",
139+
},
132140
cli.GenericFlag{
133141
Name: "type",
134142
Value: outputTypeEnum,
@@ -214,7 +222,9 @@ func runDump(ctx *cli.Context) error {
214222
fatal("Failed to include repositories: %v", err)
215223
}
216224

217-
if err := storage.LFS.IterateObjects(func(objPath string, object storage.Object) error {
225+
if ctx.IsSet("skip-lfs-data") && ctx.Bool("skip-lfs-data") {
226+
log.Info("Skip dumping LFS data")
227+
} else if err := storage.LFS.IterateObjects(func(objPath string, object storage.Object) error {
218228
info, err := object.Stat()
219229
if err != nil {
220230
return err
@@ -313,7 +323,9 @@ func runDump(ctx *cli.Context) error {
313323
}
314324
}
315325

316-
if err := storage.Attachments.IterateObjects(func(objPath string, object storage.Object) error {
326+
if ctx.IsSet("skip-attachment-data") && ctx.Bool("skip-attachment-data") {
327+
log.Info("Skip dumping attachment data")
328+
} else if err := storage.Attachments.IterateObjects(func(objPath string, object storage.Object) error {
317329
info, err := object.Stat()
318330
if err != nil {
319331
return err

0 commit comments

Comments
 (0)