Merge pull request #1350 from abperiasamy/recur-mirror-arg
Check for invalid recursive target arg
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
|
||||
+8
-5
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user