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:
@@ -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
@@ -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[] {
|
||||
|
||||
Reference in New Issue
Block a user