Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure repo_dir is empty before 'dump-repo' #20205

Merged
merged 12 commits into from
Jul 14, 2022
8 changes: 7 additions & 1 deletion cmd/dump_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package cmd
import (
"context"
"errors"
"os"
"strings"

"code.gitea.io/gitea/modules/convert"
Expand Down Expand Up @@ -159,9 +160,14 @@ func runDumpRepository(ctx *cli.Context) error {
}
}

repoDir := ctx.String("repo_dir")
if dir, _ := os.ReadDir(repoDir); len(dir) > 0 {
6543 marked this conversation as resolved.
Show resolved Hide resolved
return errors.New("`repo_dir` path '" + repoDir + "' already exists and is not an empty directory.")
}

if err := migrations.DumpRepository(
context.Background(),
ctx.String("repo_dir"),
repoDir,
ctx.String("owner_name"),
opts,
); err != nil {
Expand Down