From 2403e7a7441b85c19ff4155568b409457bd14958 Mon Sep 17 00:00:00 2001 From: kannappanr <30541348+kannappanr@users.noreply.github.com> Date: Wed, 27 May 2020 20:15:08 -0700 Subject: [PATCH] Check if destination and source are same (#3234) Fixes #3229 --- cmd/mv-main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/mv-main.go b/cmd/mv-main.go index 8715fefa..e0ae4fb4 100644 --- a/cmd/mv-main.go +++ b/cmd/mv-main.go @@ -285,6 +285,15 @@ func mainMove(ctx *cli.Context) error { // check 'copy' cli arguments. checkCopySyntax(ctx, encKeyDB, true) + if ctx.NArg() == 2 { + args := ctx.Args() + srcURL := args.Get(0) + dstURL := args.Get(1) + if srcURL == dstURL { + fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Source and destination urls cannot be the same: %v.", srcURL)) + } + } + for _, urlStr := range ctx.Args() { client, err := newClient(urlStr) if err != nil {