Support MIRAGE_CACHE_DIR env variable

This commit is contained in:
miruka 2020-06-11 21:50:26 -04:00
parent d4350f6e86
commit 451abfdf25
2 changed files with 12 additions and 4 deletions

View File

@ -73,11 +73,15 @@ or *~/.config/mirage/settings.json*.
For Flatpak users, this will be
*~/.var/app/io.github.mirukana.mirage/config/mirage* instead.
The config folder where *settings.json* is located can be overriden by
setting the `MIRAGE_CONFIG_DIR` environment variable.
The user data folder where *themes*, saved encryption data and other files
The config folder where *accounts.json* and *settings.json* is located can be
overriden by setting the `MIRAGE_CONFIG_DIR` environment variable.
The user data folder where *themes*, encryption data and interface states
are saved can be overriden with `MIRAGE_DATA_DIR`.
The cache folder where downloaded files and thumbnails are saved can be
overriden with `MIRAGE_CACHE_DIR`.
The `theme` setting can be:
- The filename of a built-in theme (`Midnight.qpl` or `Glass.qpl`)

View File

@ -2,6 +2,7 @@
import asyncio
import logging as log
import os
import sys
import traceback
from pathlib import Path
@ -102,7 +103,10 @@ class Backend:
self.send_locks: DefaultDict[str, asyncio.Lock] = \
DefaultDict(asyncio.Lock) # {room_id: lock}
cache_dir = Path(self.appdirs.user_cache_dir)
cache_dir = Path(
os.environ.get("MIRAGE_CACHE_DIR") or self.appdirs.user_cache_dir,
)
self.media_cache: MediaCache = MediaCache(self, cache_dir)