Skip to content

Commit 8711f93

Browse files
committed
Save only when new images were created
Ignore restored images when checking for new images. Restored images are still always added to the new cache. This is so that unchanged images aren't lost when other images are rebuilt.
1 parent b01c39f commit 8711f93

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

post.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ const main = async () => {
2121
assertType<string[]>(restoredImages)
2222

2323
const imageDetector = new ImageDetector()
24-
if (await imageDetector.checkIfImageHasAdded(restoredImages)) {
25-
core.info(`Key ${restoredKey} already exists, not saving cache.`)
26-
return
27-
}
2824

29-
const imagesToSave = await imageDetector.getImagesShouldSave(alreadyExistingImages)
30-
if (imagesToSave.length < 1) {
25+
const existingAndRestoredImages = alreadyExistingImages.concat(restoredImages)
26+
const newImages = await imageDetector.getImagesShouldSave(existingAndRestoredImages)
27+
if (newImages.length < 1) {
3128
core.info(`There is no image to save.`)
3229
return
3330
}
3431

32+
const imagesToSave = await imageDetector.getImagesShouldSave(alreadyExistingImages)
3533
const layerCache = new LayerCache(imagesToSave)
3634
layerCache.concurrency = parseInt(core.getInput(`concurrency`, { required: true }), 10)
3735

src/ImageDetector.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,4 @@ export class ImageDetector {
1717
alreadRegisteredImages.forEach(image => resultSet.delete(image))
1818
return Array.from(resultSet)
1919
}
20-
21-
async checkIfImageHasAdded(restoredImages: string[]): Promise<boolean> {
22-
const existing = await this.getExistingImages()
23-
return JSON.stringify(restoredImages) === JSON.stringify(existing)
24-
}
2520
}

0 commit comments

Comments
 (0)