mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
clean-up
This commit is contained in:
parent
9c2991580f
commit
92c0bced2a
11
django/core/cache/backends/filebased.py
vendored
11
django/core/cache/backends/filebased.py
vendored
@ -172,7 +172,7 @@ class FileBasedCache(BaseCache):
|
|||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def check(cls, cache, paths, name, alias_name='default'):
|
def check(cls, cache, paths, name, alias_name="default"):
|
||||||
cache_path = pathlib.Path(cache._dir).resolve()
|
cache_path = pathlib.Path(cache._dir).resolve()
|
||||||
if any(path == cache_path for path in paths):
|
if any(path == cache_path for path in paths):
|
||||||
relation = "matches"
|
relation = "matches"
|
||||||
@ -184,7 +184,8 @@ class FileBasedCache(BaseCache):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
return Warning(
|
return Warning(
|
||||||
f"Your '{alias_name}' cache configuration might expose your cache "
|
f"Your '{alias_name}' cache configuration might expose your cache "
|
||||||
f"or lead to corruption of your data because its LOCATION "
|
f"or lead to corruption of your data because its LOCATION "
|
||||||
f"{relation} {name}.", id="caches.W002",
|
f"{relation} {name}.",
|
||||||
)
|
id="caches.W002",
|
||||||
|
)
|
||||||
|
@ -22,9 +22,9 @@ def check_default_cache_is_configured(app_configs, **kwargs):
|
|||||||
@register(Tags.caches, deploy=True)
|
@register(Tags.caches, deploy=True)
|
||||||
def check_cache_location_not_exposed(app_configs, **kwargs):
|
def check_cache_location_not_exposed(app_configs, **kwargs):
|
||||||
cache = None
|
cache = None
|
||||||
alias_name = ''
|
alias_name = ""
|
||||||
for alias, config in settings.CACHES.items():
|
for alias, config in settings.CACHES.items():
|
||||||
if config.get('BACKEND').endswith("FileBasedCache"):
|
if config.get("BACKEND").endswith("FileBasedCache"):
|
||||||
cache = caches[alias]
|
cache = caches[alias]
|
||||||
alias_name = alias
|
alias_name = alias
|
||||||
|
|
||||||
@ -56,12 +56,14 @@ def check_file_based_cache_is_absolute(app_configs, **kwargs):
|
|||||||
alias_name = None
|
alias_name = None
|
||||||
location = None
|
location = None
|
||||||
for alias, config in settings.CACHES.items():
|
for alias, config in settings.CACHES.items():
|
||||||
if config.get('BACKEND').endswith("FileBasedCache"):
|
if config.get("BACKEND").endswith("FileBasedCache"):
|
||||||
alias_name = alias
|
alias_name = alias
|
||||||
location = config
|
location = config
|
||||||
|
|
||||||
if (alias_name is not None and
|
if (
|
||||||
not pathlib.Path(location.get("LOCATION")).is_absolute()):
|
alias_name is not None
|
||||||
|
and not pathlib.Path(location.get("LOCATION")).is_absolute()
|
||||||
|
):
|
||||||
return Warning(
|
return Warning(
|
||||||
f"Your '{alias_name}' cache LOCATION path is relative. Use an "
|
f"Your '{alias_name}' cache LOCATION path is relative. Use an "
|
||||||
f"absolute path instead.",
|
f"absolute path instead.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user