Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix: prevent path doubling in versioned object listing (#7729)

Chris Lu72853a3bbfce
diff --git a/weed/s3api/s3api_object_handlers_list.go b/weed/s3api/s3api_object_handlers_list.go
index a4e844df81..4d91efeb8a 100644
--- a/weed/s3api/s3api_object_handlers_list.go
+++ b/weed/s3api/s3api_object_handlers_list.go
@@ -7,6 +7,7 @@ import (
"io"
"net/http"
"net/url"
+ "path"
"sort"
"strconv"
"strings"
@@ -729,8 +730,10 @@ func (s3a *S3ApiServer) getLatestVersionEntryForListOperation(bucket, object str
// Create a logical entry that appears to be stored at the object path (not the versioned path)
// This allows the list operation to show the logical object name while preserving all metadata
+ // Use path.Base to get just the filename, since the entry.Name should be the local name only
+ // (the directory path is already included in the 'dir' parameter passed to eachEntryFn)
logicalEntry := &filer_pb.Entry{
- Name: strings.TrimPrefix(object, "/"),
+ Name: path.Base(object),
IsDirectory: false,
Attributes: latestVersionEntry.Attributes,
Extended: latestVersionEntry.Extended,