mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-05-18 06:36:37 +00:00
Make _webi/builds-cacher.js and _webi/transform-releases.js read exclusively from ~/.cache/webi/legacy/<name>.json and remove every code path that fetched from upstream or wrote to disk. The Go cache daemon (webicached) is now the sole writer; the Node server is a thin reader. builds-cacher.js: - Resolve cache files via Os.homedir() + '/.cache/webi/legacy/' instead of the cacheDir argument. Drop the 'caches' constructor parameter. - Remove getLatestBuilds / getLatestBuildsInner — they require()d per-package releases.js modules, fetched upstream, and wrote <yyyy-mm>/<name>.json + .updated.txt to disk. - Remove the process.nextTick stale-refresh hook in _doGetPackages. Cold reads return what's on disk; if the file is missing, return empty meta instead of fetching. - Remove freshenRandomPackage and its supporting state (bc._staleNames, bc._freshenTimeout, bc._staleAge). The hourly background freshener competed with webicached for the same files. - In getProjectTypeByEntry, decide selfhosted vs valid by probing for the cache file rather than require()-ing releases.js. Drop the not_found / 'PROBLEM/SOLUTION/npm clean-install' diagnostic in getProjectsByType — the cache-file probe replaces the module-load failure mode. transform-releases.js: - Remove Releases.get and the _normalize import. Replace getCachedReleases's fetch+race+stale-age machinery with a single Fs.readFile of ~/.cache/webi/legacy/<pkg>.json. - Drop the in-process version re-sort in createFormatsSorter; the cache file is already version-sorted by webicached, so the sorter only re-orders within the same version. No callers' public signatures change. Every other file is untouched — the per-package releases.js modules, _common/*.js fetchers, and _webi/normalize.js still exist on disk but are no longer reachable from the request path.
39 lines
1008 B
JavaScript
39 lines
1008 B
JavaScript
'use strict';
|
|
|
|
let Builds = module.exports;
|
|
|
|
let Path = require('node:path');
|
|
|
|
let BuildsCacher = require('./builds-cacher.js');
|
|
// let HostTargets = require('./build-classifier/host-targets.js');
|
|
let Parallel = require('./parallel.js');
|
|
|
|
var INSTALLERS_DIR = Path.join(__dirname, '..');
|
|
var CACHE_DIR = Path.join(__dirname, '../_cache');
|
|
|
|
let bc = BuildsCacher.create({
|
|
caches: CACHE_DIR,
|
|
installers: INSTALLERS_DIR,
|
|
});
|
|
|
|
Builds.init = async function () {
|
|
let dirs = await bc.getProjectsByType();
|
|
let projNames = Object.keys(dirs.valid);
|
|
|
|
let parallel = 25;
|
|
await Parallel.run(parallel, projNames, getAll);
|
|
async function getAll(name) {
|
|
void (await bc.getPackages({
|
|
//Releases: Releases,
|
|
name: name,
|
|
date: new Date(),
|
|
}));
|
|
}
|
|
};
|
|
|
|
Builds.enumerateLatestVersions = bc.enumerateLatestVersions;
|
|
Builds.findMatchingPackages = bc.findMatchingPackages;
|
|
Builds.getPackage = bc.getPackages;
|
|
Builds.getProjectType = bc.getProjectType;
|
|
Builds.selectPackage = bc.selectPackage;
|