Skip to content

Commit

Permalink
fix: exists method raises error when no file found
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks committed Jan 18, 2025
1 parent 2cc43cf commit c5d224e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions storage3/_async/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,14 @@ async def exists(
path
The path to the file.
"""
response = await self._request(
"HEAD",
f"/object/info/{self.id}/{path}",
)
return response.status_code == 200
try:
response = await self._request(
"HEAD",
f"/object/{self.id}/{path}",
)
return response.status_code == 200
except json.JSONDecodeError:
return False

async def list(
self,
Expand Down
13 changes: 8 additions & 5 deletions storage3/_sync/file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,14 @@ def exists(
path
The path to the file.
"""
response = self._request(
"HEAD",
f"/object/info/{self.id}/{path}",
)
return response.status_code == 200
try:
response = self._request(
"HEAD",
f"/object/{self.id}/{path}",
)
return response.status_code == 200
except json.JSONDecodeError:
return False

def list(
self,
Expand Down

0 comments on commit c5d224e

Please sign in to comment.