[ARVADOS] updated: 1a86e126dcc5d60666d8233a1b458591a6632190

Git user git at public.curoverse.com
Wed Jun 14 16:06:27 EDT 2017


Summary of changes:
 sdk/go/arvados/collection_fs.go      |  6 ++++--
 sdk/go/arvados/collection_fs_test.go | 25 ++++++++++++++++---------
 2 files changed, 20 insertions(+), 11 deletions(-)

       via  1a86e126dcc5d60666d8233a1b458591a6632190 (commit)
      from  510a92b885ff547dd7eecb34093f27a7245f021f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 1a86e126dcc5d60666d8233a1b458591a6632190
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Jun 14 16:05:39 2017 -0400

    8784: Fix error returned by Readdir() when count > remain.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/sdk/go/arvados/collection_fs.go b/sdk/go/arvados/collection_fs.go
index 01d5b65..89b296e 100644
--- a/sdk/go/arvados/collection_fs.go
+++ b/sdk/go/arvados/collection_fs.go
@@ -61,11 +61,13 @@ func (cd *collectionDir) Readdir(count int) ([]os.FileInfo, error) {
 	} else if len(ret) == 0 {
 		return nil, io.EOF
 	}
-	if count > len(ret) {
+	var err error
+	if count >= len(ret) {
 		count = len(ret)
+		err = io.EOF
 	}
 	cd.dirents = cd.dirents[count:]
-	return ret[:count], nil
+	return ret[:count], err
 }
 
 // Stat implements os.File.
diff --git a/sdk/go/arvados/collection_fs_test.go b/sdk/go/arvados/collection_fs_test.go
index 8cfd21e..7e8588b 100644
--- a/sdk/go/arvados/collection_fs_test.go
+++ b/sdk/go/arvados/collection_fs_test.go
@@ -45,15 +45,22 @@ func (s *CollectionFSSuite) TestReaddirFull(c *check.C) {
 func (s *CollectionFSSuite) TestReaddirLimited(c *check.C) {
 	f, err := s.fs.Open("./dir1")
 	c.Assert(err, check.IsNil)
-	for i := 0; i < 2; i++ {
-		fis, err := f.Readdir(1)
-		c.Check(err, check.IsNil)
-		c.Check(len(fis), check.Equals, 1)
-		if len(fis) > 0 {
-			c.Check(fis[0].Size(), check.Equals, int64(3))
-		}
-	}
+
 	fis, err := f.Readdir(1)
+	c.Check(err, check.IsNil)
+	c.Check(len(fis), check.Equals, 1)
+	if len(fis) > 0 {
+		c.Check(fis[0].Size(), check.Equals, int64(3))
+	}
+
+	fis, err = f.Readdir(1)
+	c.Check(err, check.Equals, io.EOF)
+	c.Check(len(fis), check.Equals, 1)
+	if len(fis) > 0 {
+		c.Check(fis[0].Size(), check.Equals, int64(3))
+	}
+
+	fis, err = f.Readdir(1)
 	c.Check(len(fis), check.Equals, 0)
 	c.Check(err, check.NotNil)
 	c.Check(err, check.Equals, io.EOF)
@@ -65,7 +72,7 @@ func (s *CollectionFSSuite) TestReaddirLimited(c *check.C) {
 	c.Assert(err, check.IsNil)
 	fis, err = f.Readdir(2)
 	c.Check(len(fis), check.Equals, 1)
-	c.Assert(err, check.IsNil)
+	c.Assert(err, check.Equals, io.EOF)
 	fis, err = f.Readdir(2)
 	c.Check(len(fis), check.Equals, 0)
 	c.Assert(err, check.Equals, io.EOF)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list