Merge pull request #939 from harshavardhana/pr_out_check_for_url_s_when_target_path_doesn_t_have_bucket_error_out_quickly

Check for url's when target path doesn't have bucket, error out quickly
This commit is contained in:
Harshavardhana
2015-07-26 19:16:30 +00:00
2 changed files with 21 additions and 0 deletions
+12
View File
@@ -85,6 +85,18 @@ func checkCastSyntax(ctx *cli.Context) {
}
}
for _, tgtURL := range tgtURLs {
url, err := client.Parse(tgtURL)
if err != nil {
console.Fatalf("Unable to parse target ‘%s’ argument. %s\n", tgtURL, NewIodine(iodine.New(err, nil)))
}
if url.Host != "" {
if url.Path == string(url.Separator) {
console.Fatalf("Bucket creation detected for %s, cloud storage URL's should use ‘mc mb’ to create buckets\n", tgtURL)
}
}
}
switch guessCastURLType(srcURL, tgtURLs) {
case castURLsTypeA: // File -> File.
checkCastSyntaxTypeA(srcURL, tgtURLs)
+9
View File
@@ -75,6 +75,15 @@ func checkCopySyntax(ctx *cli.Context) {
if isURLRecursive(tgtURL) {
console.Fatalf("Recursive option is not supported for target ‘%s’ argument. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil)))
}
url, err := client.Parse(tgtURL)
if err != nil {
console.Fatalf("Unable to parse target ‘%s’ argument. %s\n", tgtURL, NewIodine(iodine.New(err, nil)))
}
if url.Host != "" {
if url.Path == string(url.Separator) {
console.Fatalf("Bucket creation detected for %s, cloud storage URL's should use ‘mc mb’ to create buckets\n", tgtURL)
}
}
switch guessCopyURLType(srcURLs, tgtURL) {
case copyURLsTypeA: // File -> File.
checkCopySyntaxTypeA(srcURLs, tgtURL)