diff --git a/src/cache-extract-entries.ts b/src/cache-extract-entries.ts index 36411f9..576d208 100644 --- a/src/cache-extract-entries.ts +++ b/src/cache-extract-entries.ts @@ -312,9 +312,9 @@ export class GradleHomeEntryExtractor extends AbstractEntryExtractor { followSymbolicLinks: false }) - for (const p of await globber.glob()) { - cacheDebug(`Deleting wrapper zip: ${p}`) - tryDelete(p) + for (const wrapperZip of await globber.glob()) { + cacheDebug(`Deleting wrapper zip: ${wrapperZip}`) + await tryDelete(wrapperZip) } } diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 111b85a..50a6600 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -198,9 +198,12 @@ export function handleCacheFailure(error: unknown, message: string): void { */ export async function tryDelete(file: string): Promise { const maxAttempts = 5 - const stat = fs.lstatSync(file) for (let attempt = 1; attempt <= maxAttempts; attempt++) { + if (!fs.existsSync(file)) { + return + } try { + const stat = fs.lstatSync(file) if (stat.isDirectory()) { fs.rmdirSync(file, {recursive: true}) } else {