minio / mc

Unix like utilities for object store
https://min.io/download
GNU Affero General Public License v3.0
2.86k stars 548 forks source link

fix: mirror with local path #4825

Closed jiuker closed 9 months ago

jiuker commented 9 months ago

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 license. By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 license.

Description

There have path with / start when local file path. before: mc mirror --exclude "*.yaml" localPath will not work. now: it work.

Motivation and Context

How to test this PR?

Types of changes

Checklist:

jiuker commented 9 months ago

@jiuker not sure, but would this work here, 'clnt.GetURL().Separator' instead of passing the client type ? worth a try

func newClientURL(urlStr string) *ClientURL {
    scheme, rest := getScheme(urlStr)
    if strings.HasPrefix(rest, "//") {
        // if rest has '//' prefix, skip them
        var authority string
        authority, rest = splitSpecial(rest[2:], "/", false)
        if rest == "" {
            rest = "/"
        }
        host := getHost(authority)
        if host != "" && (scheme == "http" || scheme == "https") {
            return &ClientURL{
                Scheme:          scheme,
                Type:            objectStorage,
                Host:            host,
                Path:            rest,
                SchemeSeparator: "://",
                Separator:       '/',
            }
        }
    }
    return &ClientURL{
        Type:      fileSystem,
        Path:      rest,
        Separator: filepath.Separator,
    }
}

They can be the same. @vadmeste