Skip to content

Commit 205a9e3

Browse files
committed
check if root cache exists
1 parent 8d425a0 commit 205a9e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/LayerCache.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ class LayerCache {
3535
await this.separateAllLayerCaches()
3636
}
3737

38-
return await Promise.all([this.storeRoot(), ...(this.enabledParallel ? await this.storeLayers() : [])])
38+
if (await this.storeRoot() === undefined) {
39+
core.info(`cache key already exists, aborting.`)
40+
return false
41+
}
42+
43+
await Promise.all(this.enabledParallel ? await this.storeLayers() : [])
44+
return true
3945
}
4046

4147
private async saveImageAsUnpacked() {
@@ -71,7 +77,7 @@ class LayerCache {
7177
core.info(`Start storing root cache, key: ${rootKey}, dir: ${this.getUnpackedTarDir()}`)
7278
const cacheId = await LayerCache.dismissCacheAlreadyExistsError(cache.saveCache(paths, rootKey))
7379
core.info(`Stored root cache, key: ${rootKey}, id: ${cacheId}`)
74-
return cacheId
80+
return cacheId !== -1 ? cacheId : undefined
7581
}
7682

7783
private async separateAllLayerCaches() {

0 commit comments

Comments
 (0)