Skip to content

Commit

Permalink
Merge pull request #82 from rcowsill/fix/81
Browse files Browse the repository at this point in the history
Save only when new images were created
  • Loading branch information
satackey authored Dec 6, 2020
2 parents b01c39f + 8711f93 commit 94f1bef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
10 changes: 4 additions & 6 deletions post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ const main = async () => {
assertType<string[]>(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)

Expand Down
5 changes: 0 additions & 5 deletions src/ImageDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,4 @@ export class ImageDetector {
alreadRegisteredImages.forEach(image => resultSet.delete(image))
return Array.from(resultSet)
}

async checkIfImageHasAdded(restoredImages: string[]): Promise<boolean> {
const existing = await this.getExistingImages()
return JSON.stringify(restoredImages) === JSON.stringify(existing)
}
}

0 comments on commit 94f1bef

Please sign in to comment.