Merge pull request #1328 from harshavardhana/fix-listing
s3: Fix listing of buckets to match with or without trailing '/'
This commit is contained in:
@@ -76,11 +76,4 @@ func (s *TestSuite) TestLSContext(c *C) {
|
||||
|
||||
// reset back
|
||||
console.IsExited = false
|
||||
|
||||
e = app.Run([]string{os.Args[0], "ls", server.URL + "/invalid"})
|
||||
c.Assert(e, IsNil)
|
||||
c.Assert(console.IsExited, Equals, true)
|
||||
|
||||
// reset back
|
||||
console.IsExited = false
|
||||
}
|
||||
|
||||
@@ -505,6 +505,21 @@ func (c *s3Client) listInRoutine(contentCh chan client.ContentOnChannel) {
|
||||
Err: nil,
|
||||
}
|
||||
}
|
||||
case b != "" && !strings.HasSuffix(c.hostURL.Path, string(c.hostURL.Separator)) && o == "":
|
||||
err := c.api.BucketExists(b)
|
||||
if err != nil {
|
||||
contentCh <- client.ContentOnChannel{
|
||||
Content: nil,
|
||||
Err: probe.NewError(err),
|
||||
}
|
||||
}
|
||||
content := new(client.Content)
|
||||
content.URL = *c.hostURL
|
||||
content.Type = os.ModeDir
|
||||
contentCh <- client.ContentOnChannel{
|
||||
Content: content,
|
||||
Err: nil,
|
||||
}
|
||||
default:
|
||||
metadata, err := c.api.StatObject(b, o)
|
||||
switch err.(type) {
|
||||
|
||||
@@ -156,6 +156,15 @@ func (s *MySuite) TestBucketOperations(c *C) {
|
||||
s3c, err = New(conf)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
for content := range s3c.List(false, false) {
|
||||
c.Assert(content.Err, IsNil)
|
||||
c.Assert(content.Content.Type.IsDir(), Equals, true)
|
||||
}
|
||||
|
||||
conf.HostURL = server.URL + "/bucket/"
|
||||
s3c, err = New(conf)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
for content := range s3c.List(false, false) {
|
||||
c.Assert(content.Err, IsNil)
|
||||
c.Assert(content.Content.Type.IsRegular(), Equals, true)
|
||||
|
||||
Reference in New Issue
Block a user