Skip to content

Commit

Permalink
Run test cases on hns
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Oct 18, 2024
1 parent b7cc38c commit 8b559e3
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,55 +2020,57 @@ def _ls_objects(
"not version aware."
)

bucket_type = self._get_bucket_type(bucket)
# bucket_type = self._get_bucket_type(bucket)
all_results = []

if bucket_type == TOS_BUCKET_TYPE_FNS:
is_truncated = True

continuation_token = ""
while is_truncated:
is_truncated = True

def _call_list_objects_type2(
continuation_token: str = continuation_token,
) -> ListObjectType2Output:
return self.tos_client.list_objects_type2(
bucket,
prefix,
start_after=prefix if not include_self else None,
delimiter=delimiter,
max_keys=max_items,
continuation_token=continuation_token,
)
continuation_token = ""
while is_truncated:

resp = retryable_func_executor(
_call_list_objects_type2,
args=(continuation_token,),
max_retry_num=self.max_retry_num,
def _call_list_objects_type2(
continuation_token: str = continuation_token,
) -> ListObjectType2Output:
return self.tos_client.list_objects_type2(
bucket,
prefix,
start_after=prefix if not include_self else None,
delimiter=delimiter,
max_keys=max_items,
continuation_token=continuation_token,
)
is_truncated = resp.is_truncated
continuation_token = resp.next_continuation_token

all_results.extend(resp.contents + resp.common_prefixes)
elif bucket_type == TOS_BUCKET_TYPE_HNS:

def _recursive_list(bucket: str, prefix: str) -> None:
resp = retryable_func_executor(
lambda: self.tos_client.list_objects_type2(
bucket,
prefix=prefix,
delimiter="/",
max_keys=max_items,
),
max_retry_num=self.max_retry_num,
)
all_results.extend(resp.contents + resp.common_prefixes)
for common_prefix in resp.common_prefixes:
_recursive_list(bucket, common_prefix.prefix)
resp = retryable_func_executor(
_call_list_objects_type2,
args=(continuation_token,),
max_retry_num=self.max_retry_num,
)
is_truncated = resp.is_truncated
continuation_token = resp.next_continuation_token

_recursive_list(bucket, prefix)
else:
raise ValueError(f"Unsupported bucket type: {bucket_type}")
all_results.extend(resp.contents + resp.common_prefixes)

# if bucket_type == TOS_BUCKET_TYPE_FNS:
#
# elif bucket_type == TOS_BUCKET_TYPE_HNS:
#
# def _recursive_list(bucket: str, prefix: str) -> None:
# resp = retryable_func_executor(
# lambda: self.tos_client.list_objects_type2(
# bucket,
# prefix=prefix,
# delimiter="/",
# max_keys=max_items,
# ),
# max_retry_num=self.max_retry_num,
# )
# all_results.extend(resp.contents + resp.common_prefixes)
# for common_prefix in resp.common_prefixes:
# _recursive_list(bucket, common_prefix.prefix)
#
# _recursive_list(bucket, prefix)
# else:
# raise ValueError(f"Unsupported bucket type: {bucket_type}")

return all_results

Expand Down

0 comments on commit 8b559e3

Please sign in to comment.