diff --git a/cmd/ls-main.go b/cmd/ls-main.go index db6821da..c19cd8c9 100644 --- a/cmd/ls-main.go +++ b/cmd/ls-main.go @@ -165,8 +165,7 @@ func checkListSyntax(ctx context.Context, cliCtx *cli.Context) ([]string, bool, // Bucket name empty is a valid error for 'ls myminio', // treat it as such. _, buckNameEmpty := err.ToGoError().(BucketNameEmpty) - _, noPath := err.ToGoError().(PathNotFound) - if buckNameEmpty || noPath { + if buckNameEmpty { continue } fatalIf(err.Trace(url), "Unable to stat `"+url+"`.") diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index 113b2ead..0dc5fa04 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -745,15 +745,6 @@ func runMirror(ctx context.Context, cancelMirror context.CancelFunc, srcURL, dst (srcClt.GetURL().Type == objectStorage && srcClt.GetURL().Path == string(srcClt.GetURL().Separator)) - // Check if we are only trying to mirror one bucket from source. - if dstClt.GetURL().Type == objectStorage && - dstClt.GetURL().Path == string(dstClt.GetURL().Separator) && !mirrorAllBuckets { - dstURL = urlJoinPath(dstURL, srcClt.GetURL().Path) - - dstClt, err = newClient(dstURL) - fatalIf(err, "Unable to initialize `"+dstURL+"`.") - } - // Create a new mirror job and execute it mj := newMirrorJob(srcURL, dstURL, mirrorOptions{ isFake: cli.Bool("fake"), @@ -849,8 +840,31 @@ func runMirror(ctx context.Context, cancelMirror context.CancelFunc, srcURL, dst return true } } else { - mj.status.fatalIf(dstClt.MakeBucket(ctx, cli.String("region"), true, withLock), - "Unable to create bucket at `"+dstURL+"`.") + targetAlias, targetURL, _ := mustExpandAlias(srcURL) + if !strings.HasSuffix(targetURL, string(srcClt.GetURL().Separator)) { + targetURL += string(srcClt.GetURL().Separator) + } + + srcClt, err := newClientFromAlias(targetAlias, targetURL) + fatalIf(err.Trace(targetURL), "Unable to initialize target `"+targetURL+"`.") + + dstInitialURL := dstURL + for content := range srcClt.List(ctx, ListOptions{isRecursive: false, showDir: DirNone}) { + if content.Err != nil { + errorIf(content.Err.Trace(srcClt.GetURL().String()), "Unable to list folder.") + continue + } + + if content.Type.IsDir() { + dstURL = urlJoinPath(dstInitialURL, filepath.Base(content.URL.Path)+string(srcClt.GetURL().Separator)) + + dstClt, err = newClient(dstURL) + fatalIf(err, "Unable to initialize `"+dstURL+"`.") + mj.status.fatalIf(dstClt.MakeBucket(ctx, cli.String("region"), true, withLock), + "Unable to create bucket at `"+dstURL+"`.") + } + + } } // object lock configuration set on bucket