Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/ruff-0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
karpetrosyan authored Sep 5, 2024
2 parents 04c4a1e + fce0c09 commit 7ba32de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## development

- Ignore file not found error when cleaning up a file storage. (#264)

## 0.0.30 (12th July, 2024)

- Fix cache update on revalidation response with content (rfc9111 section 4.3.3) (#239)
Expand Down
11 changes: 7 additions & 4 deletions hishel/_async/_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,13 @@ async def _remove_expired_caches(self, response_path: Path) -> None:
async with self._lock:
with os.scandir(self._base_path) as entries:
for entry in entries:
if entry.is_file():
age = time.time() - entry.stat().st_mtime
if age > self._ttl:
os.unlink(entry.path)
try:
if entry.is_file():
age = time.time() - entry.stat().st_mtime
if age > self._ttl:
os.unlink(entry.path)
except FileNotFoundError: # pragma: no cover
pass


class AsyncSQLiteStorage(AsyncBaseStorage):
Expand Down
11 changes: 7 additions & 4 deletions hishel/_sync/_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,13 @@ def _remove_expired_caches(self, response_path: Path) -> None:
with self._lock:
with os.scandir(self._base_path) as entries:
for entry in entries:
if entry.is_file():
age = time.time() - entry.stat().st_mtime
if age > self._ttl:
os.unlink(entry.path)
try:
if entry.is_file():
age = time.time() - entry.stat().st_mtime
if age > self._ttl:
os.unlink(entry.path)
except FileNotFoundError: # pragma: no cover
pass


class SQLiteStorage(BaseStorage):
Expand Down

0 comments on commit 7ba32de

Please sign in to comment.