From a658f3adc0ec2bf7f1dbb13701360eeb5c4a4470 Mon Sep 17 00:00:00 2001 From: Nikita Zinkevich Date: Mon, 16 Dec 2024 13:01:50 +0300 Subject: [PATCH] [#181] index_page: Ignore deleted objects in versioned buckets Signed-off-by: Nikita Zinkevich --- internal/handler/browse.go | 42 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/internal/handler/browse.go b/internal/handler/browse.go index 2938b5c..64ad1f5 100644 --- a/internal/handler/browse.go +++ b/internal/handler/browse.go @@ -22,12 +22,13 @@ import ( ) const ( - dateFormat = "02-01-2006 15:04" - attrOID = "OID" - attrCreated = "Created" - attrFileName = "FileName" - attrFilePath = "FilePath" - attrSize = "Size" + dateFormat = "02-01-2006 15:04" + attrOID = "OID" + attrCreated = "Created" + attrFileName = "FileName" + attrFilePath = "FilePath" + attrSize = "Size" + attrDeleteMarker = "IsDeleteMarker" ) type ( @@ -39,23 +40,25 @@ type ( Objects []ResponseObject } ResponseObject struct { - OID string - Created string - FileName string - FilePath string - Size string - IsDir bool - GetURL string + OID string + Created string + FileName string + FilePath string + Size string + IsDir bool + GetURL string + IsDeleteMarker bool } ) func newListObjectsResponseS3(attrs map[string]string) ResponseObject { return ResponseObject{ - Created: formatTimestamp(attrs[attrCreated]), - OID: attrs[attrOID], - FileName: attrs[attrFileName], - Size: attrs[attrSize], - IsDir: attrs[attrOID] == "", + Created: formatTimestamp(attrs[attrCreated]), + OID: attrs[attrOID], + FileName: attrs[attrFileName], + Size: attrs[attrSize], + IsDir: attrs[attrOID] == "", + IsDeleteMarker: attrs[attrDeleteMarker] == "true", } } @@ -179,6 +182,9 @@ func (h *Handler) getDirObjectsS3(ctx context.Context, bucketInfo *data.BucketIn attrs[m.GetKey()] = string(m.GetValue()) } obj := newListObjectsResponseS3(attrs) + if obj.IsDeleteMarker { + continue + } obj.FilePath = prefix + obj.FileName obj.GetURL = "/get/" + bucketInfo.Name + urlencode(obj.FilePath) result.objects = append(result.objects, obj)