Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits:
1513c674 by Mark Sapiro at 2021-04-17T08:55:02-07:00
Use mailman.utilities.filesystem.safe_remove() function.
- - - - -
98c22773 by Mark Sapiro at 2021-04-17T16:20:15+00:00
Merge branch 'dry' into 'master'
Use mailman.utilities.filesystem.safe_remove() function.
See merge request mailman/mailman!832
- - - - -
1 changed file:
- src/mailman/model/cache.py
Changes:
=====================================
src/mailman/model/cache.py
=====================================
@@ -20,7 +20,7 @@
import os
import hashlib
-from contextlib import ExitStack, suppress
+from contextlib import ExitStack
from lazr.config import as_timedelta
from mailman.config import config
from mailman.database.model import Model
@@ -28,6 +28,7 @@ from mailman.database.transaction import dbconnection
from mailman.database.types import SAUnicode
from mailman.interfaces.cache import ICacheManager
from mailman.utilities.datetime import now
+from mailman.utilities.filesystem import safe_remove
from public import public
from sqlalchemy import Boolean, Column, DateTime, Integer
from zope.interface import implementer
@@ -142,8 +143,7 @@ class CacheManager:
# Do we expunge the cache file?
if expunge:
store.delete(entry)
- with suppress(FileNotFoundError):
- os.remove(file_path)
+ safe_remove(file_path)
return contents
@dbconnection
@@ -154,8 +154,7 @@ class CacheManager:
if entry is None:
return
file_path, dir_path = self._id_to_path(entry.file_id)
- with suppress(FileNotFoundError):
- os.remove(file_path)
+ safe_remove(file_path)
store.delete(entry)
@dbconnection
@@ -169,8 +168,7 @@ class CacheManager:
.all())
for entry in expired_entries:
file_path, _ = self._id_to_path(entry.file_id)
- with suppress(FileNotFoundError):
- os.remove(file_path)
+ safe_remove(file_path)
store.delete(entry)
@dbconnection
@@ -179,6 +177,5 @@ class CacheManager:
# but for now there probably aren't that many cached files.
for entry in store.query(CacheEntry):
file_path, dir_path = self._id_to_path(entry.file_id)
- with suppress(FileNotFoundError):
- os.remove(file_path)
+ safe_remove(file_path)
store.delete(entry)
View it on GitLab:
https://gitlab.com/mailman/mailman/-/compare/8d746e37106e576514baacc30dba35e57d7f8ff7...98c22773beae41f563f4febb865f73979ee55e38
--
View it on GitLab:
https://gitlab.com/mailman/mailman/-/compare/8d746e37106e576514baacc30dba35e57d7f8ff7...98c22773beae41f563f4febb865f73979ee55e38
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: [email protected]