mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-11-08 21:49:00 +08:00
Only perform post-restore and pre-save cache actions when required
This commit is contained in:
@@ -109,6 +109,9 @@ export abstract class AbstractCache {
|
||||
core.info(
|
||||
`${this.cacheDescription} restored from cache key: ${cacheResult}`
|
||||
)
|
||||
|
||||
await this.afterRestore()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -134,6 +137,8 @@ export abstract class AbstractCache {
|
||||
}
|
||||
}
|
||||
|
||||
protected async afterRestore(): Promise<void> {}
|
||||
|
||||
async save(): Promise<void> {
|
||||
if (!this.cacheOutputExists()) {
|
||||
this.debug(`No ${this.cacheDescription} to cache.`)
|
||||
@@ -157,6 +162,8 @@ export abstract class AbstractCache {
|
||||
return
|
||||
}
|
||||
|
||||
await this.beforeSave()
|
||||
|
||||
core.info(
|
||||
`Caching ${this.cacheDescription} with cache key: ${cacheKey}`
|
||||
)
|
||||
@@ -166,6 +173,8 @@ export abstract class AbstractCache {
|
||||
return
|
||||
}
|
||||
|
||||
protected async beforeSave(): Promise<void> {}
|
||||
|
||||
protected async saveCache(
|
||||
cachePath: string[],
|
||||
cacheKey: string
|
||||
|
||||
Reference in New Issue
Block a user