diff --git a/tosfs/core.py b/tosfs/core.py index a72bff4..5d3634b 100644 --- a/tosfs/core.py +++ b/tosfs/core.py @@ -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