Skip to content

repository in the config is not used anymore #438

Open

Description

following up #420

I ended up there while bisecting repositoryrepositoryBase 's silent (and partialy a breaking) change. I believe this PR removed support of setting repository in the configuration file, which makes tldr fallback to default assets instead of the specified one. To handle this:

  • Update documentation according to the code (to supply a base url and construct the actual download inside tldr) and note it's a breaking change
  • Add a condition to allow all-language download if repository was specified (this makes it backwards compatible)

I think one of the two (prefferably both) of the above measures should be taken. (I think the second one should be implemented with a deprecation warning of some form as it's inefficient for both the client and the server)(if we're going to implement it)

Affected codes between prior to #420 and the current main branch (7ad3c5a..c58c92c):

  • config.json:

    "repository": "https://tldr.sh/assets/tldr.zip",

    "repositoryBase": "https://tldr.sh/assets/tldr-pages",

  • lib/cache.js

    .then(() => {
    // Download and extract cache data to temporary folder
    return remote.download(tempFolder);
    })

    .then(() => {
    // Download and extract cache data to temporary folder
    return Promise.allSettled(this.config.languages.map((lang) => {
    return remote.download(tempFolder, lang);
    }));
    })

  • lib/remote.js

    exports.download = (path) => {
    const url = config.get().repository;

    exports.download = (loc, lang) => {
    // If the lang is english then keep the url simple, otherwise add language.
    const suffix = (lang === 'en' ? '' : '.' + lang);
    const url = config.get().repositoryBase + suffix + '.zip';
    const folderName = path.join(loc, 'pages' + suffix);
    const REQUEST_TIMEOUT = 10000;

I don't have time currently to make a PR on my own now, so I would appreciate if someone could handle this. However if this remains for a month or two, maybe I can put my hands on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions