[arvados] updated: 2.7.0-5596-g98cfc0a392

git repository hosting git at public.arvados.org
Wed Dec 13 00:04:54 UTC 2023


Summary of changes:
 sdk/go/arvados/fs_base.go      | 10 +++++++++-
 sdk/go/arvados/fs_site_test.go | 10 ++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

       via  98cfc0a3924a16654150899afbb7fd255439cec3 (commit)
      from  3d5a798ef6f4bd3b1a771bacdf0acf70edf6c1f5 (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 98cfc0a3924a16654150899afbb7fd255439cec3
Author: Tom Clegg <tom at curii.com>
Date:   Tue Dec 12 19:03:58 2023 -0500

    21214: Fix lookup of file with trailing slash.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/fs_base.go b/sdk/go/arvados/fs_base.go
index 1841d79f99..430a0d4c9b 100644
--- a/sdk/go/arvados/fs_base.go
+++ b/sdk/go/arvados/fs_base.go
@@ -787,7 +787,15 @@ func rlookup(start inode, path string, visited map[inode]bool) (node inode, err
 		visited = map[inode]bool{}
 	}
 	node = start
-	for _, name := range strings.Split(filepath.Clean(path), "/") {
+	// Clean up ./ and ../ and double-slashes, but (unlike
+	// filepath.Clean) retain a trailing slash, because looking up
+	// ".../regularfile/" should fail.
+	trailingSlash := strings.HasSuffix(path, "/")
+	path = filepath.Clean(path)
+	if trailingSlash && path != "/" {
+		path += "/"
+	}
+	for _, name := range strings.Split(path, "/") {
 		visited[node] = true
 		if node.IsDir() {
 			if name == "." || name == "" {
diff --git a/sdk/go/arvados/fs_site_test.go b/sdk/go/arvados/fs_site_test.go
index c7d6b2a464..2c86536b2f 100644
--- a/sdk/go/arvados/fs_site_test.go
+++ b/sdk/go/arvados/fs_site_test.go
@@ -185,6 +185,16 @@ func (s *SiteFSSuite) TestByUUIDAndPDH(c *check.C) {
 		names = append(names, fi.Name())
 	}
 	c.Check(names, check.DeepEquals, []string{"baz"})
+	f, err = s.fs.Open("/by_id/" + fixtureAProjectUUID + "/A Subproject/baz_file/baz")
+	c.Assert(err, check.IsNil)
+	err = f.Close()
+	c.Assert(err, check.IsNil)
+	_, err = s.fs.Open("/by_id/" + fixtureAProjectUUID + "/A Subproject/baz_file/baz/")
+	c.Assert(err, check.Equals, ErrNotADirectory)
+	_, err = s.fs.Open("/by_id/" + fixtureAProjectUUID + "/A Subproject/baz_file/baz/z")
+	c.Assert(err, check.Equals, ErrNotADirectory)
+	_, err = s.fs.Open("/by_id/" + fixtureAProjectUUID + "/A Subproject/baz_file/baz/..")
+	c.Assert(err, check.Equals, ErrNotADirectory)
 
 	_, err = s.fs.OpenFile("/by_id/"+fixtureNonexistentCollection, os.O_RDWR|os.O_CREATE, 0755)
 	c.Check(err, ErrorIs, ErrInvalidOperation)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list