mirror of
https://github.com/django/django.git
synced 2025-04-04 13:36:42 +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
|
||||
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()
|
||||
if any(path == cache_path for path in paths):
|
||||
relation = "matches"
|
||||
@ -184,7 +184,8 @@ class FileBasedCache(BaseCache):
|
||||
return None
|
||||
|
||||
return Warning(
|
||||
f"Your '{alias_name}' cache configuration might expose your cache "
|
||||
f"or lead to corruption of your data because its LOCATION "
|
||||
f"{relation} {name}.", id="caches.W002",
|
||||
)
|
||||
f"Your '{alias_name}' cache configuration might expose your cache "
|
||||
f"or lead to corruption of your data because its LOCATION "
|
||||
f"{relation} {name}.",
|
||||
id="caches.W002",
|
||||
)
|
||||
|
@ -22,9 +22,9 @@ def check_default_cache_is_configured(app_configs, **kwargs):
|
||||
@register(Tags.caches, deploy=True)
|
||||
def check_cache_location_not_exposed(app_configs, **kwargs):
|
||||
cache = None
|
||||
alias_name = ''
|
||||
alias_name = ""
|
||||
for alias, config in settings.CACHES.items():
|
||||
if config.get('BACKEND').endswith("FileBasedCache"):
|
||||
if config.get("BACKEND").endswith("FileBasedCache"):
|
||||
cache = caches[alias]
|
||||
alias_name = alias
|
||||
|
||||
@ -56,12 +56,14 @@ def check_file_based_cache_is_absolute(app_configs, **kwargs):
|
||||
alias_name = None
|
||||
location = None
|
||||
for alias, config in settings.CACHES.items():
|
||||
if config.get('BACKEND').endswith("FileBasedCache"):
|
||||
if config.get("BACKEND").endswith("FileBasedCache"):
|
||||
alias_name = alias
|
||||
location = config
|
||||
|
||||
if (alias_name is not None and
|
||||
not pathlib.Path(location.get("LOCATION")).is_absolute()):
|
||||
if (
|
||||
alias_name is not None
|
||||
and not pathlib.Path(location.get("LOCATION")).is_absolute()
|
||||
):
|
||||
return Warning(
|
||||
f"Your '{alias_name}' cache LOCATION path is relative. Use an "
|
||||
f"absolute path instead.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user