Skip to content

Commit

Permalink
cmd/sync: fix the dst password is not removed (#4390)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Jan 31, 2024
1 parent d46d208 commit 67ba75f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
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++ {
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

0 comments on commit 67ba75f

Please sign in to comment.