5
0
mirror of https://gitea.com/actions/setup-java.git synced 2026-08-05 02:31:18 +00:00

Apply batched suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges
2026-08-04 19:33:29 -04:00
committed by GitHub
parent ee3e6d82d3
commit 7091818a1e
2 changed files with 15 additions and 8 deletions
+10 -5
View File
@@ -324,18 +324,23 @@ export abstract class JavaBase {
}
protected getJdkCachePath(version: string): string {
const toolCache = process.env['RUNNER_TOOL_CACHE'];
if (!toolCache) {
return '';
}
return path.join(
process.env['RUNNER_TOOL_CACHE'] ?? '',
toolCache,
this.toolcacheFolderName,
this.getToolcacheVersionName(version)
);
}
protected getRestoredJdkPath(version: string): string | null {
const architecturePath = path.join(
this.getJdkCachePath(version),
this.architecture
);
const basePath = this.getJdkCachePath(version);
if (!basePath) {
return null;
}
const architecturePath = path.join(basePath, this.architecture);
return fs.existsSync(architecturePath) &&
fs.existsSync(`${architecturePath}.complete`)
? architecturePath
+5 -3
View File
@@ -99,18 +99,20 @@ export async function saveJdkCaches(): Promise<void> {
}
export function buildJdkCacheKey(jdk: JdkCache): string {
const runnerOs = process.env['RUNNER_OS'] ?? process.platform;
const normalizedArchitecture = jdk.architecture.toLowerCase();
const identity = JSON.stringify({
keyVersion: JDK_CACHE_KEY_VERSION,
runnerOs: process.env['RUNNER_OS'] ?? process.platform,
runnerOs,
platform: process.platform,
distribution: jdk.distribution.toLowerCase(),
packageType: jdk.packageType.toLowerCase(),
architecture: jdk.architecture.toLowerCase(),
architecture: normalizedArchitecture,
version: jdk.version,
source: jdk.source
});
const digest = createHash('sha256').update(identity).digest('hex');
return `setup-java-jdk-v${JDK_CACHE_KEY_VERSION}-${process.env['RUNNER_OS'] ?? process.platform}-${jdk.architecture}-${digest}`;
return `setup-java-jdk-v${JDK_CACHE_KEY_VERSION}-${runnerOs}-${normalizedArchitecture}-${digest}`;
}
function parseJdkCacheState(state: string): JdkCacheState[] {