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

cmd/sync: fix the src password is not removed #4390

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,19 @@ func setup(c *cli.Context, n int) {
}
}

func removePassword(uri string) {
func removePassword(uris ...string) {
args := make([]string, len(os.Args))
copy(args, os.Args)
uri2 := utils.RemovePassword(uri)
if uri2 != uri {
for i, a := range os.Args {
if a == uri {
args[i] = uri2
break
var idx int
for _, uri := range uris {
uri2 := utils.RemovePassword(uri)
if uri2 != uri {
for i := idx; i < len(os.Args); i++ {
davies marked this conversation as resolved.
Show resolved Hide resolved
if os.Args[i] == uri {
args[i] = uri2
idx = i + 1
break
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ func doSync(c *cli.Context) error {
// Windows support `\` and `/` as its separator, Unix only use `/`
srcURL := c.Args().Get(0)
dstURL := c.Args().Get(1)
removePassword(srcURL)
removePassword(dstURL)
removePassword(srcURL, dstURL)
if runtime.GOOS == "windows" {
if !strings.Contains(srcURL, "://") {
srcURL = strings.Replace(srcURL, "\\", "/", -1)
Expand Down
Loading