Skip to content

Commit 8d896d0

Browse files
committed
Add skip custom directory option
Signed-off-by: Andrew Thornton <[email protected]>
1 parent cdabff7 commit 8d896d0

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

cmd/dump.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
157157
Name: "skip-log, L",
158158
Usage: "Skip the log dumping",
159159
},
160+
cli.BoolFlag{
161+
Name: "skip-custom-dir",
162+
Usage: "Skip custom directory",
163+
},
160164
cli.GenericFlag{
161165
Name: "type",
162166
Value: outputTypeEnum,
@@ -297,17 +301,21 @@ func runDump(ctx *cli.Context) error {
297301
}
298302
}
299303

300-
customDir, err := os.Stat(setting.CustomPath)
301-
if err == nil && customDir.IsDir() {
302-
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
303-
if err := addRecursiveExclude(w, "custom", setting.CustomPath, []string{absFileName}, verbose); err != nil {
304-
fatal("Failed to include custom: %v", err)
304+
if ctx.IsSet("skip-custom-dir") && ctx.Bool("skip-custom-dir") {
305+
log.Info("Skiping custom directory")
306+
} else {
307+
customDir, err := os.Stat(setting.CustomPath)
308+
if err == nil && customDir.IsDir() {
309+
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
310+
if err := addRecursiveExclude(w, "custom", setting.CustomPath, []string{absFileName}, verbose); err != nil {
311+
fatal("Failed to include custom: %v", err)
312+
}
313+
} else {
314+
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
305315
}
306316
} else {
307-
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
317+
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
308318
}
309-
} else {
310-
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
311319
}
312320

313321
isExist, err := util.IsExist(setting.AppDataPath)

docs/content/doc/usage/command-line.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ in the current directory.
253253
- `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
254254
- `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
255255
- `--skip-repository`, `-R`: Skip the repository dumping. Optional.
256+
- `--skip-custom-dir`: Skip dumping of the custom dir. Optional.
256257
- `--database`, `-d`: Specify the database SQL syntax. Optional.
257258
- `--verbose`, `-V`: If provided, shows additional details. Optional.
258259
- Examples:

0 commit comments

Comments
 (0)