diff --git a/cp_mirror_test.go b/cp_mirror_test.go index cc789fd6..7acdca26 100644 --- a/cp_mirror_test.go +++ b/cp_mirror_test.go @@ -79,7 +79,7 @@ func (s *TestSuite) TestMirror(c *C) { // reset back console.IsExited = false - err = app.Run([]string{os.Args[0], "mirror", filepath.Join(source, "..."), target}) + err = app.Run([]string{os.Args[0], "mirror", source, target}) c.Assert(err, IsNil) c.Assert(console.IsExited, Equals, false) diff --git a/mirror-url.go b/mirror-url.go index 26b7fb01..1a974dfe 100644 --- a/mirror-url.go +++ b/mirror-url.go @@ -52,6 +52,14 @@ func checkMirrorSyntax(ctx *cli.Context) { cli.ShowCommandHelpAndExit(ctx, "mirror", 1) // last argument is exit code. } + // Check if any of the arg is recursive type. + for _, arg := range ctx.Args() { + // Recursive URLs are not allowed in target. + if isURLRecursive(arg) { + fatalIf(errDummy().Trace(), fmt.Sprintf("Recursive option is not supported for target ā€˜%s’ argument.", arg)) + } + } + // extract URLs. URLs, err := args2URLs(ctx.Args()) fatalIf(err.Trace(ctx.Args()...), "Unable to parse arguments.") @@ -76,11 +84,6 @@ func checkMirrorSyntax(ctx *cli.Context) { } for _, tgtURL := range tgtURLs { - // Recursive URLs are not allowed in target. - if isURLRecursive(tgtURL) { - fatalIf(errDummy().Trace(), fmt.Sprintf("Recursive option is not supported for target ā€˜%s’ argument.", tgtURL)) - } - url := client.NewURL(tgtURL) if url.Host != "" { if url.Path == string(url.Separator) {