diff --git a/docs/admin/config.rst b/docs/admin/config.rst index fde3917ce115..5a5b93c1a75f 100644 --- a/docs/admin/config.rst +++ b/docs/admin/config.rst @@ -267,6 +267,21 @@ You can pass additional arguments to :command:`borg create` when built-in backup :ref:`backup`, :doc:`borg:usage/create` +.. setting:: CACHE_DIR + +CACHE_DIR +--------- + +.. versionadded:: 4.16 + +Directory where Weblate stores cache files. Defaults to :file:`cache` subfolder +in :setting:`DATA_DIR`. + +Change this to local or temporary filesystem if :setting:`DATA_DIR` is on a +network filesystem. + +The Docker container uses a separate volume for this, see :ref:`docker-volume`. + .. setting:: CSP_SCRIPT_SRC .. setting:: CSP_IMG_SRC .. setting:: CSP_CONNECT_SRC @@ -409,6 +424,10 @@ The following subdirectories usually exist: Celery scheduler data, see :ref:`celery`. :file:`fonts`: User-uploaded fonts, see :ref:`fonts`. +:file:`cache` + Various caches, can be placed elsewhere using :setting:`CACHE_DIR`. + + The Docker container uses a separate volume for this, see :ref:`docker-volume`. .. note:: @@ -426,7 +445,8 @@ Defaults to ``/home/weblate/data``, but it is expected to be configured. .. seealso:: :ref:`file-permissions`, - :doc:`backup` + :doc:`backup`, + :setting:`CACHE_DIR` .. setting:: DATABASE_BACKUP diff --git a/docs/admin/install/docker.rst b/docs/admin/install/docker.rst index fea62fd99c8f..f42387ea80e6 100644 --- a/docs/admin/install/docker.rst +++ b/docs/admin/install/docker.rst @@ -1601,8 +1601,8 @@ consist of name of your docker-compose directory, container, and volume names). In the container it is mounted as :file:`/app/data`. The cache volume is mounted as :file:`/app/cache` and is used to store static -files. Its content is recreated on container startup and the volume can be -mounted using ephemeral filesystem such as `tmpfs`. +files and :setting:`CACHE_DIR`. Its content is recreated on container startup +and the volume can be mounted using ephemeral filesystem such as `tmpfs`. When creating the volumes manually, the directories should be owned by UID 1000 as that is user used inside the container. diff --git a/weblate/settings_example.py b/weblate/settings_example.py index 6cd60827cd38..bef732543e90 100644 --- a/weblate/settings_example.py +++ b/weblate/settings_example.py @@ -66,6 +66,7 @@ # Data directory, you can use following for the development purposes: # os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data") DATA_DIR = "/home/weblate/data" +CACHE_DIR = f"{DATA_DIR}/cache" # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name diff --git a/weblate/settings_test.py b/weblate/settings_test.py index 32991a97b6ee..21b7de7bf8a5 100644 --- a/weblate/settings_test.py +++ b/weblate/settings_test.py @@ -54,6 +54,7 @@ else: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DATA_DIR = os.path.join(BASE_DIR, "data-test") +CACHE_DIR = os.path.join(DATA_DIR, "cache") MEDIA_ROOT = os.path.join(DATA_DIR, "media") STATIC_ROOT = os.path.join(DATA_DIR, "static") CELERY_BEAT_SCHEDULE_FILENAME = os.path.join(DATA_DIR, "celery", "beat-schedule") diff --git a/weblate/trans/models/_conf.py b/weblate/trans/models/_conf.py index 8a9c6d4234a0..cbece675a286 100644 --- a/weblate/trans/models/_conf.py +++ b/weblate/trans/models/_conf.py @@ -9,6 +9,9 @@ class WeblateConf(AppConf): # Data directory DATA_DIR = None + # Cache directory + CACHE_DIR = None + # Akismet API key AKISMET_API_KEY = None diff --git a/weblate/utils/data.py b/weblate/utils/data.py index 93916d0c6431..e2b3f6c9d735 100644 --- a/weblate/utils/data.py +++ b/weblate/utils/data.py @@ -10,4 +10,6 @@ def data_dir(component, *args): """Return path to data dir for given component.""" + if component == "cache" and settings.CACHE_DIR: + return os.path.join(settings.CACHE_DIR, *args) return os.path.join(settings.DATA_DIR, component, *args)