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 eea8369 commit 97a829c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,16 @@ def isdir(self, path: str) -> bool:
key = key.rstrip("/") + "/"

try:
return retryable_func_executor(
resp = retryable_func_executor(
lambda: self.tos_client.head_object(bucket, key) and True,
max_retry_num=self.max_retry_num,
)
if self._is_fns_bucket(bucket):
return True
else:
if "x-tos-directory" not in resp.header._store:
return False
return resp.header._store["x-tos-directory"][1].lower() == "true"
except TosClientError as e:
raise e
except TosServerError as e:
Expand Down Expand Up @@ -884,10 +890,16 @@ def isfile(self, path: str) -> bool:
return False

try:
return retryable_func_executor(
lambda: self.tos_client.head_object(bucket, key) and True,
resp = retryable_func_executor(
lambda: self.tos_client.head_object(bucket, key),
max_retry_num=self.max_retry_num,
)
if self._is_fns_bucket(bucket):
return True
else:
if "x-tos-directory" not in resp.header._store:
return True
return resp.header._store["x-tos-directory"][1].lower() != "true"
except TosClientError as e:
raise e
except TosServerError as e:
Expand Down Expand Up @@ -2189,6 +2201,12 @@ def _get_bucket_type(self, bucket: str) -> str:

return bucket_type

def _is_hns_bucket(self, bucket: str) -> bool:
return self._get_bucket_type(bucket) == TOS_BUCKET_TYPE_HNS

def _is_fns_bucket(self, bucket: str) -> bool:
return self._get_bucket_type(bucket) == TOS_BUCKET_TYPE_FNS

def _init_tag_manager(self) -> None:
auth = self.tos_client.auth
if isinstance(auth, CredentialProviderAuth):
Expand Down

0 comments on commit 97a829c

Please sign in to comment.