Only restore configuration-cache if Gradle Home is fully restored

Fixes #107
This commit is contained in:
Daz DeBoer
2021-10-29 08:44:08 -06:00
parent 079e4844d6
commit 9edc2a11bd
4 changed files with 48 additions and 21 deletions

View File

@@ -13,10 +13,16 @@ export async function restore(buildRootDirectory: string): Promise<void> {
await core.group('Restore Gradle state from cache', async () => {
core.saveState(BUILD_ROOT_DIR, buildRootDirectory)
return Promise.all([
new GradleUserHomeCache(buildRootDirectory).restore(),
new ProjectDotGradleCache(buildRootDirectory).restore()
])
const gradleHomeRestore = await new GradleUserHomeCache(buildRootDirectory).restore()
const projectDotGradleCache = new ProjectDotGradleCache(buildRootDirectory)
if (gradleHomeRestore.fullyRestored) {
// Only restore the configuration-cache if the Gradle Home is fully restored
await projectDotGradleCache.restore()
} else {
// Otherwise, prepare the cache key for later save()
projectDotGradleCache.prepareCacheKey()
}
})
}