Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache directory (or tldr checkout directory) to config #156

Open
slippycheeze opened this issue Nov 29, 2020 · 3 comments
Open

Add cache directory (or tldr checkout directory) to config #156

slippycheeze opened this issue Nov 29, 2020 · 3 comments

Comments

@slippycheeze
Copy link

G'day. I use a couple different tldr clients, and so rather than maintaining multiple caches I just keep my own git checkout around and updated regularly.

I can get tealdeer to use that by way of export TEALDEER_CACHE_DIR="${HOME}/var/cache" and naming the checkout tldr-master under it. Which is kind of ugly, but whatever.

It'd be great if I could just add cache = ~/var/cache (or, better, tldr = ~/var/cache/tldr) to the config.toml and never have to worry about the environment variable again. (in the second example, that'd be the path to the directory with the content, so that you didn't need append anything to the directory to get the page root.)

@niklasmohrin
Copy link
Collaborator

We could also consider just unpacking the tldr repo directly into the TEALDEER_CACHE_DIR. This is only an option, if we don't need to put anything else in the cache, but I wouldn't know what (caching of rendered pages for performance incoming? 😆).

@hgaiser
Copy link
Contributor

hgaiser commented Oct 16, 2021

Hopefully #212 will fix this issue :).

@dbrgn dbrgn changed the title add cache directory (or tldr checkout directory) to config Add cache directory (or tldr checkout directory) to config Oct 16, 2021
@dbrgn
Copy link
Owner

dbrgn commented Oct 16, 2021

Right now, the cache directory is expected to be a cache under the control of tealdeer. This is shown for example in the PR #206, where we are adding a migration that renames the checkout directory, and - if both exist - deletes the old directory.

If we add the option to externally manage the tldr repo checkout, then enabling this feature should disable all cache management functionality in tealdeer to avoid conflicts. However, that shouldn't be the same as configuring the cache directory. The directory layout inside the cache directory is not an API, and I do not want to guarantee a specific structure.

I do agree that TEALDEER_CACHE_DIR is a bit of an outlier. Initially we just had this env variable to configure tealdeer, and no config file. Then we added the config file. Now that this config file exists, there's no reason why the cache directory should be configured through an env var, and not through the config.

TLDR:

  • Making the cache directory configurable through the config file makes sense. The env var should then be deprecated (and a deprecation warning should be shown if it's still set).
  • We do not guarantee any specific layout inside this cache directory, and tealdeer may modify/rename/delete files inside that directory at any time. Pointing the cache directory to a shared dir is risky.
  • If people would like to manage the tldr pages themselves, this should be a separate option and it should disable all cache management functionality. However, I suspect that this would add significant complexity to the sourcecode, and I'd be reluctant to merge such a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants