diff --git a/cp-url.go b/cp-url.go index df5d12e5..42d500d7 100644 --- a/cp-url.go +++ b/cp-url.go @@ -224,7 +224,10 @@ func prepareCopyURLsTypeA(sourceURL string, targetURL string) copyURLs { // Source is not a regular file return copyURLs{Error: errInvalidSource(sourceURL).Trace()} } - + if sourceURL == targetURL { + // source and target can not be same + return copyURLs{Error: errSourceTargetSame(sourceURL).Trace()} + } // All OK.. We can proceed. Type A return copyURLs{SourceContent: sourceContent, TargetContent: &client.Content{URL: *client.NewURL(targetURL)}} } diff --git a/typed-errors.go b/typed-errors.go index 57cd1ea1..7933eae9 100644 --- a/typed-errors.go +++ b/typed-errors.go @@ -66,4 +66,8 @@ var ( errSourceIsDir = func(URL string) *probe.Error { return probe.NewError(errors.New("Source ‘" + URL + "’ is a folder.")).Untrace() } + + errSourceTargetSame = func(URL string) *probe.Error { + return probe.NewError(errors.New("Source and target URL can not be same : " + URL)).Untrace() + } )