[#181] index_page: Ignore deleted objects in versioned buckets
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
This commit is contained in:
parent
a945a947ac
commit
a658f3adc0
1 changed files with 24 additions and 18 deletions
|
@ -22,12 +22,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dateFormat = "02-01-2006 15:04"
|
dateFormat = "02-01-2006 15:04"
|
||||||
attrOID = "OID"
|
attrOID = "OID"
|
||||||
attrCreated = "Created"
|
attrCreated = "Created"
|
||||||
attrFileName = "FileName"
|
attrFileName = "FileName"
|
||||||
attrFilePath = "FilePath"
|
attrFilePath = "FilePath"
|
||||||
attrSize = "Size"
|
attrSize = "Size"
|
||||||
|
attrDeleteMarker = "IsDeleteMarker"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -39,23 +40,25 @@ type (
|
||||||
Objects []ResponseObject
|
Objects []ResponseObject
|
||||||
}
|
}
|
||||||
ResponseObject struct {
|
ResponseObject struct {
|
||||||
OID string
|
OID string
|
||||||
Created string
|
Created string
|
||||||
FileName string
|
FileName string
|
||||||
FilePath string
|
FilePath string
|
||||||
Size string
|
Size string
|
||||||
IsDir bool
|
IsDir bool
|
||||||
GetURL string
|
GetURL string
|
||||||
|
IsDeleteMarker bool
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func newListObjectsResponseS3(attrs map[string]string) ResponseObject {
|
func newListObjectsResponseS3(attrs map[string]string) ResponseObject {
|
||||||
return ResponseObject{
|
return ResponseObject{
|
||||||
Created: formatTimestamp(attrs[attrCreated]),
|
Created: formatTimestamp(attrs[attrCreated]),
|
||||||
OID: attrs[attrOID],
|
OID: attrs[attrOID],
|
||||||
FileName: attrs[attrFileName],
|
FileName: attrs[attrFileName],
|
||||||
Size: attrs[attrSize],
|
Size: attrs[attrSize],
|
||||||
IsDir: attrs[attrOID] == "",
|
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())
|
attrs[m.GetKey()] = string(m.GetValue())
|
||||||
}
|
}
|
||||||
obj := newListObjectsResponseS3(attrs)
|
obj := newListObjectsResponseS3(attrs)
|
||||||
|
if obj.IsDeleteMarker {
|
||||||
|
continue
|
||||||
|
}
|
||||||
obj.FilePath = prefix + obj.FileName
|
obj.FilePath = prefix + obj.FileName
|
||||||
obj.GetURL = "/get/" + bucketInfo.Name + urlencode(obj.FilePath)
|
obj.GetURL = "/get/" + bucketInfo.Name + urlencode(obj.FilePath)
|
||||||
result.objects = append(result.objects, obj)
|
result.objects = append(result.objects, obj)
|
||||||
|
|
Loading…
Reference in a new issue