From 36c6dcdac9ac8b10c5d4f29d9b5f40b3f2fb7932 Mon Sep 17 00:00:00 2001 From: Anton Kopti Date: Tue, 2 Jul 2024 12:43:05 -0400 Subject: [PATCH] discard 0 byte placeholder object when listing --- blobstore/list.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/blobstore/list.go b/blobstore/list.go index 5f6906b..1f9002b 100644 --- a/blobstore/list.go +++ b/blobstore/list.go @@ -104,6 +104,10 @@ func (bh *BlobHandler) HandleListByPrefix(c echo.Context) error { } for _, object := range page.Contents { // Handle files + // Skip zero-byte objects that match a common prefix with a trailing slash + if *object.Size == 0 && strings.HasSuffix(*object.Key, "/") { + continue + } if fullAccess || IsPermittedPrefix(bucket, *object.Key, permissions) { result = append(result, aws.StringValue(object.Key)) } @@ -185,6 +189,10 @@ func (bh *BlobHandler) HandleListByPrefixWithDetail(c echo.Context) error { for _, object := range page.Contents { // Handle files + // Skip zero-byte objects that match a common prefix with a trailing slash + if *object.Size == 0 && strings.HasSuffix(*object.Key, "/") { + continue + } if fullAccess || IsPermittedPrefix(bucket, *object.Key, permissions) { file := ListResult{ ID: count,