mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
a3d265d45d
* refactor(datasource): stop double-caching releases at the index level 15 datasources set `caching = true`, which makes the registry wrapper in `lib/modules/datasource/index.ts` store every `getReleases` result under `datasource-releases-<id>` for 15 minutes, while their own `cached()` wrapper already stores the same result under `datasource-<id>` with a longer TTL and stale-fallback. Drop `caching` from those 15; the four that rely on the index cache alone (dart-version, flutter-version, maven, pypi) keep it. `caching` is documented as requiring the datasource to return the `isPrivate` flag, and none of these 15 ever set it, so the index layer was caching private results unconditionally. The remaining `cached()` layer honours `cachePrivatePackages` as before. Also fix two cache-key/registry defects found alongside: - `galaxy-collection` declares `registryStrategy = 'hunt'` but keyed its cache on the package name only, so a `null` from the first hunted registry was replayed for the second one. The registry URL is now part of the key, which invalidates existing entries once. - `typst` ignores `config.registryUrl` and always reads its default registry, so it now sets `customRegistrySupport = false`. A configured `registryUrls` for typst is now warned about and ignored instead of being silently dropped. * Merge branch 'main' into secustor/refactor/datasource-remove-index-caching
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { logger } from '../../../logger/index.ts';
|
|
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { adoptiumRegistryUrl, getAdoptiumReleases } from './adoptium.ts';
|
|
import { datasource, parsePackage } from './common.ts';
|
|
import { getGraalvmReleases, graalvmRegistryUrl } from './graalvm.ts';
|
|
|
|
export class JavaVersionDatasource extends Datasource {
|
|
static readonly id = datasource;
|
|
|
|
constructor() {
|
|
super(datasource);
|
|
}
|
|
|
|
override getDefaultRegistryUrls(packageName: string): string[] {
|
|
return packageName.includes('oracle-graalvm')
|
|
? [graalvmRegistryUrl]
|
|
: [adoptiumRegistryUrl];
|
|
}
|
|
|
|
override supportsCustomRegistry(packageName: string): boolean {
|
|
return packageName.includes('oracle-graalvm');
|
|
}
|
|
|
|
private async fetchReleases({
|
|
registryUrl,
|
|
packageName,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
const pkgConfig = parsePackage(packageName);
|
|
logger.trace(
|
|
{ registryUrl, packageName, pkgConfig },
|
|
'fetching java release',
|
|
);
|
|
|
|
try {
|
|
if (pkgConfig.vendor === 'oracle-graalvm') {
|
|
const effectiveRegistryUrl = registryUrl ?? graalvmRegistryUrl;
|
|
return await getGraalvmReleases(
|
|
this.http,
|
|
pkgConfig,
|
|
effectiveRegistryUrl,
|
|
);
|
|
}
|
|
|
|
// Default to Adoptium
|
|
return await getAdoptiumReleases(this.http, pkgConfig);
|
|
} catch (err) {
|
|
this.handleGenericErrors(err);
|
|
}
|
|
}
|
|
|
|
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
return this.cached(
|
|
{
|
|
key: `${config.registryUrl}:${config.packageName}`,
|
|
cacheable: true,
|
|
fallback: true,
|
|
},
|
|
() => this.fetchReleases(config),
|
|
);
|
|
}
|
|
}
|