This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new 83211ec8a fix(io): accept a trailing slash on the blobfs WalkDir root
(#2218)
83211ec8a is described below
commit 83211ec8a9df85357526bf8afe0ef5be466817dd
Author: Revanth <[email protected]>
AuthorDate: Mon Oct 19 15:06:25 2026 -0500
fix(io): accept a trailing slash on the blobfs WalkDir root (#2218)
---
io/gocloud/blobfs/blob.go | 7 ++++++-
io/gocloud/blobfs/blob_test.go | 33 +++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/io/gocloud/blobfs/blob.go b/io/gocloud/blobfs/blob.go
index 19a6474b4..e260db8b2 100644
--- a/io/gocloud/blobfs/blob.go
+++ b/io/gocloud/blobfs/blob.go
@@ -550,7 +550,12 @@ func (bfs *FileIO) WalkDir(root string, fn fs.WalkDirFunc)
error {
walkPath = "."
} else {
- walkPath = location.key
+ // fs.WalkDir rejects a path with a trailing slash, and a
directory
+ // root is often written with one.
+ walkPath = strings.TrimRight(location.key, "/")
+ if walkPath == "" {
+ walkPath = "."
+ }
}
return fs.WalkDir(walkFS{bfs}, walkPath, func(path string, d
fs.DirEntry, err error) error {
diff --git a/io/gocloud/blobfs/blob_test.go b/io/gocloud/blobfs/blob_test.go
index 272833207..57228b271 100644
--- a/io/gocloud/blobfs/blob_test.go
+++ b/io/gocloud/blobfs/blob_test.go
@@ -936,6 +936,39 @@ func TestBlobFileIOWalkDirSkipsSubdirectoryMarkers(t
*testing.T) {
}, files)
}
+// TestBlobFileIOWalkDirTrailingSlashRoot checks that a root written with a
+// trailing slash walks the same paths as the root without one.
+func TestBlobFileIOWalkDirTrailingSlashRoot(t *testing.T) {
+ ctx := context.Background()
+
+ bucket := memblob.OpenBucket(nil)
+ defer bucket.Close()
+
+ require.NoError(t, bucket.WriteAll(ctx, "tbl/data/a.parquet",
[]byte("a"), nil))
+ require.NoError(t, bucket.WriteAll(ctx,
"tbl/metadata/v1.metadata.json", []byte("b"), nil))
+
+ bfs := testBlobFileIO(ctx, "mybucket", bucket)
+
+ walk := func(root string) []string {
+ var paths []string
+ require.NoError(t, bfs.WalkDir(root, func(path string, _
fs.DirEntry, err error) error {
+ if err != nil {
+ return err
+ }
+ paths = append(paths, path)
+
+ return nil
+ }), root)
+
+ return paths
+ }
+
+ want := walk("s3://mybucket/tbl")
+ require.Len(t, want, 5)
+ assert.Equal(t, want, walk("s3://mybucket/tbl/"))
+ assert.Equal(t, want, walk("s3://mybucket/tbl//"))
+}
+
func TestBlobFileIORemoveAll(t *testing.T) {
ctx := context.Background()
bucket := memblob.OpenBucket(nil)