summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-04-15 16:41:47 +0100
committerGitHub <noreply@github.com>2021-04-15 18:41:47 +0300
commit802a4314ef6cd4b8c905cb7254c1aea85ad1bc45 (patch)
tree225a5f1e52ea62b1d2214c276801b742569416c9
parentedd4ab49c8c0554a4983effc1d0b5487191717a5 (diff)
downloadgitea-802a4314ef6cd4b8c905cb7254c1aea85ad1bc45.tar.gz
gitea-802a4314ef6cd4b8c905cb7254c1aea85ad1bc45.zip
dump: Add option to skip LFS/attachment files (#15407) (#15492)
Backport #15407 * Add option to skip dumping LFS/attachment files * Fix fmt issues Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Johan Van de Wauw <johan@gisky.be> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
-rw-r--r--cmd/dump.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/cmd/dump.go b/cmd/dump.go
index 43997c8da8..458f9f91e0 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -129,6 +129,14 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
Name: "skip-custom-dir",
Usage: "Skip custom directory",
},
+ cli.BoolFlag{
+ Name: "skip-lfs-data",
+ Usage: "Skip LFS data",
+ },
+ cli.BoolFlag{
+ Name: "skip-attachment-data",
+ Usage: "Skip attachment data",
+ },
cli.GenericFlag{
Name: "type",
Value: outputTypeEnum,
@@ -214,7 +222,9 @@ func runDump(ctx *cli.Context) error {
fatal("Failed to include repositories: %v", err)
}
- if err := storage.LFS.IterateObjects(func(objPath string, object storage.Object) error {
+ if ctx.IsSet("skip-lfs-data") && ctx.Bool("skip-lfs-data") {
+ log.Info("Skip dumping LFS data")
+ } else if err := storage.LFS.IterateObjects(func(objPath string, object storage.Object) error {
info, err := object.Stat()
if err != nil {
return err
@@ -313,7 +323,9 @@ func runDump(ctx *cli.Context) error {
}
}
- if err := storage.Attachments.IterateObjects(func(objPath string, object storage.Object) error {
+ if ctx.IsSet("skip-attachment-data") && ctx.Bool("skip-attachment-data") {
+ log.Info("Skip dumping attachment data")
+ } else if err := storage.Attachments.IterateObjects(func(objPath string, object storage.Object) error {
info, err := object.Stat()
if err != nil {
return err