Opened 3 years ago

Closed 3 years ago

#32180 closed Cleanup/optimization (fixed)

Add a warning if the file system cache location is relative.

Reported by: Carles Pina Estany Owned by: Carles Pina Estany
Component: Core (System checks) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Carles Pina Estany)

FileBasedCache LOCATION: the documentation says that the path should be absolute, Django accepts absolute or relative.

In https://docs.djangoproject.com/en/3.1/topics/cache/#filesystem-caching

It says:
"The directory path should be absolute – that is, it should start at the root of your filesystem."

The code makes them absolute:
https://github.com/django/django/blob/master/django/core/cache/backends/filebased.py#L22

Enforcing the LOCATION to be specified only in absolute way might have no gain and would have backwards compatibility problems for deployments that are passing the directory using a relative path.

A possible way to improve the situation without or minimal backwards incompatibility changes would be to add a new check (thanks Carlton for the idea).

I'm happy to make any changes:
https://github.com/django/django/pull/13655

Change History (4)

comment:1 by Carles Pina Estany, 3 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 3 years ago

Component: Core (Cache system)Core (System checks)
Patch needs improvement: set
Summary: FileBasedCache accepts relative directorires as a LOCATION documentation say should be absoluteAdd a warning if the file system cache location is relative.
Triage Stage: UnreviewedAccepted

comment:3 by Mariusz Felisiak, 3 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 721c95ba:

Fixed #32180 -- Added system check for file system caches absolute location.

Note: See TracTickets for help on using tickets.
Back to Top