Compare commits

...

3 Commits

Author SHA1 Message Date
Ploum 0a9fb62582 check that the cache_path ends with / 2024-01-23 21:21:15 +01:00
prx 87837fd1fb implement set cache directory
Hi,
find below a patch which let user set a custom chache folder.

Environment variable OFFPUNK_CACHE_PATH is used.
This way, it can be set globally in a profile, or occasionnaly before running offpunk.
It also avoid the pain to parse options and dealing with flags in scripts.
Thank you for your attention.

Regards.

prx
2024-01-23 21:11:52 +01:00
Ploum 01de6fe6ae changelog update 2024-01-23 14:12:22 +01:00
3 changed files with 19 additions and 3 deletions

View File

@ -2,10 +2,11 @@
## 2.2 - Unpublished ## 2.2 - Unpublished
- cache folder is now configurable through $OFFPUNK_CACHE_PATH environment variable (by prx)
- offpunk: adding an URL to a list now update the view mode if url already present - offpunk: adding an URL to a list now update the view mode if url already present
- netcache : solve an infinite gemini loop with code 6X (see also bug #31) - netcache: solve an infinite gemini loop with code 6X (see also bug #31)
- ansicat: added support for <video> HTML-element - ansicat: added support for <video> HTML-element
- ansicat: if chafa fails to load an image, fallback to timg is available - ansicat: if chafa fails to load an image, fallback to timg if available
- offpunk: add list autocompletion to "tour" - offpunk: add list autocompletion to "tour"
- offpunk: removed "blackbox", which has not been used nor maintained - offpunk: removed "blackbox", which has not been used nor maintained
- offpunk: "gus" was broken, it is functionnal again - offpunk: "gus" was broken, it is functionnal again

View File

@ -27,6 +27,15 @@ otherwise it would always refresh it from the version available online.
It is also useful for mapping a given URL to its location in the cache, It is also useful for mapping a given URL to its location in the cache,
independently of whether it has been downloaded first. independently of whether it has been downloaded first.
.Pp .Pp
Default cache path is
.Pa ~/.cache/offpunk .
Set
.Ev OFFPUNK_CACHE_PATH
environment variable to use another location.
.Bd -literal
OFFPUNK_CACHE_PATH=/home/ploum/custom-cache netcache.py gemini://some.url
.Ed
.Pp
.Xr Offpunk 1 .Xr Offpunk 1
is a command-line browser and feed reader dedicated to browsing the Web, is a command-line browser and feed reader dedicated to browsing the Web,
Gemini, Gopher and Spartan. Gemini, Gopher and Spartan.

View File

@ -62,9 +62,15 @@ def xdg(folder="cache"):
#if no XDG .local/share and not XDG .config, we use the old config #if no XDG .local/share and not XDG .config, we use the old config
if not os.path.exists(data_home) and os.path.exists(_old_config): if not os.path.exists(data_home) and os.path.exists(_old_config):
_DATA_DIR = _CONFIG_DIR _DATA_DIR = _CONFIG_DIR
## get _CACHE_PATH from OFFPUNK_CACHE_PATH environment variable
# if OFFPUNK_CACHE_PATH empty, set default to ~/.cache/offpunk
cache_home = os.environ.get('XDG_CACHE_HOME') or\ cache_home = os.environ.get('XDG_CACHE_HOME') or\
os.path.join(_home,'.cache') os.path.join(_home,'.cache')
_CACHE_PATH = os.path.join(os.path.expanduser(cache_home),"offpunk/") _CACHE_PATH = os.environ.get('OFFPUNK_CACHE_PATH', \
os.path.join(os.path.expanduser(cache_home),"offpunk/"))
#Check that the cache path ends with "/"
if not _CACHE_PATH.endswith("/"):
_CACHE_PATH += "/"
os.makedirs(_CACHE_PATH,exist_ok=True) os.makedirs(_CACHE_PATH,exist_ok=True)
if folder == "cache" and not UPGRADED: if folder == "cache" and not UPGRADED:
upgrade_cache(_CACHE_PATH) upgrade_cache(_CACHE_PATH)