Unverified Commit 93c31ca3 authored by Daz DeBoer's avatar Daz DeBoer
Browse files

Don't fail if the file-to-delete no longer exists

Fixes #308
parent 7a150053
Loading
Loading
Loading
Loading
+3 −3
Changes for src/cache-extract-entries.ts: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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)
        }
    }

+4 −1
Changes for src/cache-utils.ts: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -198,9 +198,12 @@ export function handleCacheFailure(error: unknown, message: string): void {
 */
export async function tryDelete(file: string): Promise<void> {
    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 {