Improve cache-reporting when entry already exists

This commit is contained in:
Daz DeBoer 2022-01-19 12:11:51 -07:00
parent a23ac1d61c
commit 0a5ede19a9
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
4 changed files with 34 additions and 23 deletions

View file

@ -130,16 +130,13 @@ export class GradleStateCache {
restoreKeys:[${cacheKey.restoreKeys}]`
)
const cacheResult = await restoreCache(this.getCachePath(), cacheKey.key, cacheKey.restoreKeys)
entryListener.markRequested(cacheKey.key, cacheKey.restoreKeys)
const cacheResult = await restoreCache(this.getCachePath(), cacheKey.key, cacheKey.restoreKeys, entryListener)
if (!cacheResult) {
core.info(`${this.cacheDescription} cache not found. Will initialize empty.`)
return
}
core.saveState(this.cacheResultStateKey, cacheResult.key)
entryListener.markRestored(cacheResult.key, cacheResult.size)
core.info(`Restored ${this.cacheDescription} from cache key: ${cacheResult.key}`)
@ -186,11 +183,8 @@ export class GradleStateCache {
core.info(`Caching ${this.cacheDescription} with cache key: ${cacheKeyFromRestore}`)
const cachePath = this.getCachePath()
const savedEntry = await saveCache(cachePath, cacheKeyFromRestore)
if (savedEntry) {
listener.entry(this.cacheDescription).markSaved(savedEntry.key, savedEntry.size)
}
const entryListener = listener.entry(this.cacheDescription)
await saveCache(cachePath, cacheKeyFromRestore, entryListener)
return
}