Report the cache as disabled when Gradle User Home exists

Fixes #434
This commit is contained in:
daz
2023-08-19 12:37:50 -06:00
parent 8cade330d4
commit 68e1dcdea4
3 changed files with 26 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ export class CacheListener {
cacheReadOnly = false
cacheWriteOnly = false
cacheDisabled = false
cacheDisabledReason = 'disabled'
get fullyRestored(): boolean {
return this.cacheEntries.every(x => !x.wasRequestedButNotRestored())
@@ -17,7 +18,7 @@ export class CacheListener {
get cacheStatus(): string {
if (!cache.isFeatureAvailable()) return 'not available'
if (this.cacheDisabled) return 'disabled'
if (this.cacheDisabled) return this.cacheDisabledReason
if (this.cacheWriteOnly) return 'write-only'
if (this.cacheReadOnly) return 'read-only'
return 'enabled'

View File

@@ -29,6 +29,8 @@ export async function restore(gradleUserHome: string, cacheListener: CacheListen
core.info('Gradle User Home already exists: will not restore from cache.')
// Initialize pre-existing Gradle User Home.
gradleStateCache.init()
cacheListener.cacheDisabled = true
cacheListener.cacheDisabledReason = 'disabled due to pre-existing Gradle User Home'
return
}