Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Aug 26, 2024
1 parent 9c0e4ec commit e74af9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ def isfile(self, path: str) -> bool:
True if the path is a file, False otherwise.
"""
if path.endswith("/"):
return False

bucket, key, _ = self._split_path(path)
try:
# Attempt to get the object metadata
Expand Down
3 changes: 2 additions & 1 deletion tosfs/tests/test_tosfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def test_isfile(tosfs: TosFileSystem, bucket: str, temporary_workspace: str) ->
file_name = random_path()
tosfs.tos_client.put_object(bucket=bucket, key=f"{temporary_workspace}/{file_name}")
assert tosfs.isfile(f"{bucket}/{temporary_workspace}/{file_name}")
assert tosfs.isfile(f"{bucket}/{temporary_workspace}/{file_name}/")
assert not tosfs.isfile(f"{bucket}/{temporary_workspace}/{file_name}/")
assert not tosfs.isfile(f"{bucket}/{temporary_workspace}/nonexistfile")
assert not tosfs.isfile(f"{bucket}/{temporary_workspace}")
assert not tosfs.isfile(f"{bucket}/{temporary_workspace}/")

Expand Down

0 comments on commit e74af9f

Please sign in to comment.