diff --git a/post.ts b/post.ts index e6162d99..a3a977d2 100644 --- a/post.ts +++ b/post.ts @@ -21,17 +21,15 @@ const main = async () => { assertType(restoredImages) const imageDetector = new ImageDetector() - if (await imageDetector.checkIfImageHasAdded(restoredImages)) { - core.info(`Key ${restoredKey} already exists, not saving cache.`) - return - } - const imagesToSave = await imageDetector.getImagesShouldSave(alreadyExistingImages) - if (imagesToSave.length < 1) { + const existingAndRestoredImages = alreadyExistingImages.concat(restoredImages) + const newImages = await imageDetector.getImagesShouldSave(existingAndRestoredImages) + if (newImages.length < 1) { core.info(`There is no image to save.`) return } + const imagesToSave = await imageDetector.getImagesShouldSave(alreadyExistingImages) const layerCache = new LayerCache(imagesToSave) layerCache.concurrency = parseInt(core.getInput(`concurrency`, { required: true }), 10) diff --git a/src/ImageDetector.ts b/src/ImageDetector.ts index 24d42b01..905881ac 100644 --- a/src/ImageDetector.ts +++ b/src/ImageDetector.ts @@ -17,9 +17,4 @@ export class ImageDetector { alreadRegisteredImages.forEach(image => resultSet.delete(image)) return Array.from(resultSet) } - - async checkIfImageHasAdded(restoredImages: string[]): Promise { - const existing = await this.getExistingImages() - return JSON.stringify(restoredImages) === JSON.stringify(existing) - } }