diff --git a/pkg/client/fs/fs.go b/pkg/client/fs/fs.go index dfe9a967..ab74a3a0 100644 --- a/pkg/client/fs/fs.go +++ b/pkg/client/fs/fs.go @@ -241,11 +241,6 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { pathURL := *f.PathURL fpath := pathURL.Path - // Golang strips trailing / if you clean(..) or - // EvalSymlinks(..). Adding '.' prevents it from doing so. - if strings.HasSuffix(fpath, string(pathURL.Separator)) { - fpath = fpath + "." - } fst, err := f.fsStat() if err != nil { @@ -312,6 +307,21 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { return } + // if the directory doesn't end with a separator, do not traverse it. + if !strings.HasSuffix(fpath, string(pathURL.Separator)) && fst.Mode().IsDir() { + content := &client.Content{ + URL: pathURL, + Time: fst.ModTime(), + Size: fst.Size(), + Type: fst.Mode(), + } + contentCh <- client.ContentOnChannel{ + Content: content, + Err: nil, + } + return + } + switch fst.Mode().IsDir() { case true: // do not use ioutil.ReadDir(), since it tries to sort its diff --git a/pkg/client/fs/fs_test.go b/pkg/client/fs/fs_test.go index 64431a2a..5f605beb 100644 --- a/pkg/client/fs/fs_test.go +++ b/pkg/client/fs/fs_test.go @@ -69,11 +69,8 @@ func (s *MySuite) TestList(c *C) { contents = append(contents, contentCh.Content) } c.Assert(perr, IsNil) - c.Assert(len(contents), Equals, 2) - - for _, content := range contents { - c.Assert(content.Type.IsRegular(), Equals, true) - } + c.Assert(len(contents), Equals, 1) + c.Assert(contents[0].Type.IsDir(), Equals, true) objectPath = filepath.Join(root, "test1/newObject1") fsc, perr = fs.New(objectPath) @@ -94,15 +91,8 @@ func (s *MySuite) TestList(c *C) { contents = append(contents, contentCh.Content) } c.Assert(perr, IsNil) - c.Assert(len(contents), Equals, 3) - - for _, content := range contents { - // skip previous regular files - if content.Type.IsRegular() { - continue - } - c.Assert(content.Type.IsDir(), Equals, true) - } + c.Assert(len(contents), Equals, 1) + c.Assert(contents[0].Type.IsDir(), Equals, true) fsc, perr = fs.New(root) c.Assert(err, IsNil)