Skip to content

Commit 94f1bef

Browse files
authored
Merge pull request #82 from rcowsill/fix/81
Save only when new images were created
2 parents b01c39f + 8711f93 commit 94f1bef

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)