Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/client-fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"time"

"github.com/google/uuid"

"github.com/pkg/xattr"
"github.com/rjeczalik/notify"

Expand Down
17 changes: 17 additions & 0 deletions cmd/client-s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,10 @@ func (c *S3Client) listVersionsRoutine(ctx context.Context, b, o string, opts Li
buckets = append(buckets, b)
}

if opts.Prefix != "" {
o = opts.Prefix
}

for _, b := range buckets {
var skipKey string
for objectVersion := range c.api.ListObjects(ctx, b, minio.ListObjectsOptions{
Expand Down Expand Up @@ -2104,6 +2108,10 @@ func (c *S3Client) listIncompleteInRoutine(ctx context.Context, contentCh chan *
func (c *S3Client) listIncompleteRecursiveInRoutine(ctx context.Context, contentCh chan *ClientContent, opts ListOptions) {
// get bucket and object from URL.
b, o := c.url2BucketAndObject()
if opts.Prefix != "" {
o = opts.Prefix
}

switch {
case b == "" && o == "":
buckets, err := c.api.ListBuckets(ctx)
Expand Down Expand Up @@ -2243,6 +2251,7 @@ func (c *S3Client) objectInfo2ClientContent(bucket string, entry minio.ObjectInf
}
url.Path = c.buildAbsPath(bucket, entry.Key)
content.URL = url
content.ObjectKey = entry.Key
content.BucketName = bucket
content.Size = entry.Size
content.ETag = entry.ETag
Expand Down Expand Up @@ -2321,6 +2330,10 @@ func (c *S3Client) bucketStat(ctx context.Context, opts BucketStatOptions) (*Cli
func (c *S3Client) listInRoutine(ctx context.Context, contentCh chan *ClientContent, opts ListOptions) {
// get bucket and object from URL.
b, o := c.url2BucketAndObject()
if opts.Prefix != "" {
o = opts.Prefix
}

if opts.ListZip && (b == "" || o == "") {
contentCh <- &ClientContent{
Err: probe.NewError(errors.New("listing zip files must provide bucket and object")),
Expand Down Expand Up @@ -2385,6 +2398,10 @@ func sortBucketsNameWithSlash(bucketsInfo []minio.BucketInfo) {
func (c *S3Client) listRecursiveInRoutine(ctx context.Context, contentCh chan *ClientContent, opts ListOptions) {
// get bucket and object from URL.
b, o := c.url2BucketAndObject()
if opts.Prefix != "" {
o = opts.Prefix
}

switch {
case b == "" && o == "":
buckets, err := c.api.ListBuckets(ctx)
Expand Down
12 changes: 8 additions & 4 deletions cmd/client-url.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,14 @@ func (u ClientURL) String() string {
}

// urlJoinPath Join a path to existing URL.
func urlJoinPath(url1, url2 string) string {
u1 := newClientURL(url1)
u2 := newClientURL(url2)
return joinURLs(u1, u2).String()
func urlJoinPath(base, element string) string {
if strings.HasSuffix(base, "/") && strings.HasPrefix(element, "/") {
return base + element[1:]
}
if !strings.HasSuffix(base, "/") && !strings.HasPrefix(element, "/") {
return base + "/" + element
}
return base + element
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have to test with URLs @Laisky just thinking that base and element are just paths is not going to work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laisky can you let met know why this change is needed?


// url2Stat returns stat info for URL - supports bucket, object and a prefixe with or without a trailing slash
Expand Down
2 changes: 2 additions & 0 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type ListOptions struct {
TimeRef time.Time
ShowDir DirOpt
Count int
Prefix string // Add prefix support
}

// CopyOptions holds options for copying operation
Expand Down Expand Up @@ -213,6 +214,7 @@ type Client interface {
// ClientContent - Content container for content metadata
type ClientContent struct {
URL ClientURL
ObjectKey string
BucketName string // only valid and set for client-type objectStorage
Time time.Time
Size int64
Expand Down
Loading
Loading