-
-
Notifications
You must be signed in to change notification settings - Fork 76
Description
following up #420
I ended up there while bisecting repository
→ repositoryBase
'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:
Line 3 in 7ad3c5a
"repository": "https://tldr.sh/assets/tldr.zip",
Line 3 in c58c92c
"repositoryBase": "https://tldr.sh/assets/tldr-pages", -
lib/cache.js
Lines 53 to 56 in 7ad3c5a
.then(() => { // Download and extract cache data to temporary folder return remote.download(tempFolder); })
Lines 51 to 56 in c58c92c
.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
tldr-node-client/lib/remote.js
Lines 8 to 9 in 7ad3c5a
exports.download = (path) => { const url = config.get().repository;
tldr-node-client/lib/remote.js
Lines 10 to 15 in c58c92c
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.