Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list_objects(): identify delete marker generically #1106

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions minio/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def __init__(self, # pylint: disable=too-many-arguments
last_modified=None, etag=None,
size=None, metadata=None,
version_id=None, is_latest=None, storage_class=None,
owner_id=None, owner_name=None, content_type=None):
owner_id=None, owner_name=None, content_type=None,
is_delete_marker=False):
self._bucket_name = bucket_name
self._object_name = object_name
self._last_modified = last_modified
Expand All @@ -101,6 +102,7 @@ def __init__(self, # pylint: disable=too-many-arguments
self._owner_id = owner_id
self._owner_name = owner_name
self._content_type = content_type
self._is_delete_marker = is_delete_marker

@property
def bucket_name(self):
Expand Down Expand Up @@ -165,15 +167,15 @@ def owner_name(self):
@property
def is_delete_marker(self):
"""Get whether this key is a delete marker."""
return self._size is None and self._version_id is not None
return self._is_delete_marker

@property
def content_type(self):
"""Get content type."""
return self._content_type

@classmethod
def fromxml(cls, element, bucket_name):
def fromxml(cls, element, bucket_name, is_delete_marker=False):
"""Create new object with values from XML element."""
tag = findtext(element, "LastModified")
last_modified = None if tag is None else from_iso8601utc(tag)
Expand Down Expand Up @@ -208,6 +210,7 @@ def fromxml(cls, element, bucket_name):
owner_id=owner_id,
owner_name=owner_name,
metadata=metadata,
is_delete_marker=is_delete_marker,
)


Expand All @@ -228,7 +231,7 @@ def parse_list_objects(response, bucket_name):
]

elements = findall(element, "DeleteMarker")
objects += [Object.fromxml(tag, bucket_name) for tag in elements]
objects += [Object.fromxml(tag, bucket_name, True) for tag in elements]

is_truncated = (findtext(element, "IsTruncated") or "").lower() == "true"
key_marker = findtext(element, "NextKeyMarker")
Expand Down