From 65a31e34c9923477213e97befe90229880222de8 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Fri, 15 Apr 2016 16:59:38 -0700 Subject: [PATCH] check if sources exist (#1685) --- client-fs.go | 5 ++--- cp-url-syntax.go | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client-fs.go b/client-fs.go index 77c23a01..3d915ab5 100644 --- a/client-fs.go +++ b/client-fs.go @@ -298,10 +298,9 @@ func (f *fsClient) Remove(incomplete bool) *probe.Error { // List - list files and folders. func (f *fsClient) List(recursive, incomplete bool) <-chan *clientContent { contentCh := make(chan *clientContent) - switch recursive { - case true: + if recursive { go f.listRecursiveInRoutine(contentCh, incomplete) - default: + } else { go f.listInRoutine(contentCh, incomplete) } return contentCh diff --git a/cp-url-syntax.go b/cp-url-syntax.go index dba11c3f..550a42f3 100644 --- a/cp-url-syntax.go +++ b/cp-url-syntax.go @@ -38,6 +38,14 @@ func checkCopySyntax(ctx *cli.Context) { isRecursive := ctx.Bool("recursive") /****** Generic Invalid Rules *******/ + // Verify if source(s) exists. + for _, srcURL := range srcURLs { + _, _, err := url2Stat(srcURL) + if err != nil { + fatalIf(err.Trace(srcURL), fmt.Sprintf("Unable to stat '%s'.", srcURL)) + } + } + // Check if bucket name is passed for URL type arguments. url := newClientURL(tgtURL) if url.Host != "" {