Commit e3d60b38 authored by Paul Merlin's avatar Paul Merlin
Browse files

Protect wrapper cache restore against tar errors

parent 2dd6cc18
Loading
Loading
Loading
Loading
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+11 −2
Changes for src/cache-wrapper.ts: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ export async function restoreCachedWrapperDist(
    if (!wrapperSlug) return

    const wrapperCacheKey = `wrapper-${wrapperSlug}`
    const wrapperCachePath = path.join(
    const wrapperCachePath = path.resolve(
        os.homedir(),
        `.gradle/wrapper/dists/gradle-${wrapperSlug}`
    )
@@ -35,6 +35,7 @@ export async function restoreCachedWrapperDist(
    core.saveState(WRAPPER_CACHE_KEY, wrapperCacheKey)
    core.saveState(WRAPPER_CACHE_PATH, wrapperCachePath)

    try {
        const restoredKey = await cache.restoreCache(
            [wrapperCachePath],
            wrapperCacheKey
@@ -48,9 +49,17 @@ export async function restoreCachedWrapperDist(
        }

        core.saveState(WRAPPER_CACHE_RESULT, restoredKey)
    core.info(`Wrapper installation restored from cache key: ${restoredKey}`)
        core.info(
            `Wrapper installation restored from cache key: ${restoredKey}`
        )
        return
    } catch (error) {
        core.info(
            `Wrapper installation cache restore failed, expect a Gradle distribution download\n  ${error}`
        )
        return
    }
}

export async function cacheWrapperDist(): Promise<void> {
    if (isWrapperCacheDisabled()) return