summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-02-08 15:23:41 -0800
committerTim Graham <timograham@gmail.com>2019-02-08 18:23:41 -0500
commite42b788960bbc3271d64c128c801843b9e116c24 (patch)
tree1254b071ecb31cfc19df596cef23ed36367d5c24
parent25829197bb94585e94695360065ac614aa9e6a56 (diff)
Simplified FileBasedCache.clear().
glob.glob1() ignores missing paths.
-rw-r--r--django/core/cache/backends/filebased.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/django/core/cache/backends/filebased.py b/django/core/cache/backends/filebased.py
index f507011050..48b8df90ab 100644
--- a/django/core/cache/backends/filebased.py
+++ b/django/core/cache/backends/filebased.py
@@ -129,8 +129,6 @@ class FileBasedCache(BaseCache):
"""
Remove all the cache files.
"""
- if not os.path.exists(self._dir):
- return
for fname in self._list_cache_files():
self._delete(fname)
@@ -153,8 +151,7 @@ class FileBasedCache(BaseCache):
Get a list of paths to all the cache files. These are all the files
in the root cache dir that end on the cache_suffix.
"""
- if not os.path.exists(self._dir):
- return []
- filelist = [os.path.join(self._dir, fname) for fname
- in glob.glob1(self._dir, '*%s' % self.cache_suffix)]
- return filelist
+ return [
+ os.path.join(self._dir, fname)
+ for fname in glob.glob1(self._dir, '*%s' % self.cache_suffix)
+ ]