Fix StorageManager.list(“s3://..”, with_metadata=True) doesn't work

This commit is contained in:
allegroai 2022-11-19 00:58:05 +02:00
parent 035a76e282
commit 0b0fd55329

View File

@ -611,6 +611,7 @@ class StorageHelper(object):
""" """
if not obj: if not obj:
return None return None
size = None
try: try:
if isinstance(self._driver, _HttpDriver) and obj: if isinstance(self._driver, _HttpDriver) and obj:
obj = self._driver._get_download_object(obj) # noqa obj = self._driver._get_download_object(obj) # noqa
@ -1556,6 +1557,7 @@ class _Boto3Driver(_Driver):
@attrs @attrs
class ListResult(object): class ListResult(object):
name = attrib(default=None) name = attrib(default=None)
size = attrib(default=None)
def __init__(self): def __init__(self):
pass pass
@ -1617,7 +1619,7 @@ class _Boto3Driver(_Driver):
else: else:
res = container.bucket.objects.all() res = container.bucket.objects.all()
for res in res: for res in res:
yield self.ListResult(name=res.key) yield self.ListResult(name=res.key, size=res.size)
def delete_object(self, object, **kwargs): def delete_object(self, object, **kwargs):
from botocore.exceptions import ClientError from botocore.exceptions import ClientError