From ae501048f59646fc688fe0373f938096dab5bd7f Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Tue, 18 Jan 2022 11:44:40 +0000 Subject: [PATCH] Ensure the `finish` event is always reported when fetching images Change-type: patch --- src/compose/images.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/compose/images.ts b/src/compose/images.ts index e57185c6..d8ca7aaf 100644 --- a/src/compose/images.ts +++ b/src/compose/images.ts @@ -172,7 +172,7 @@ export function imageFromService(service: ServiceInfo): Image { export async function triggerFetch( image: Image, opts: FetchOptions, - onFinish = _.noop, + onFinish: (success: boolean) => void, serviceName: string, ): Promise { const appUpdatePollInterval = await config.get('appUpdatePollInterval'); @@ -202,8 +202,7 @@ export async function triggerFetch( let success: boolean; try { const imageName = normalise(image.name); - image = _.clone(image); - image.name = imageName; + image = { ...image, name: imageName }; // Look for a matching image on the engine const img = await inspectByName(image.name); @@ -214,8 +213,7 @@ export async function triggerFetch( // Create image on the database if it already exists on the engine await markAsSupervised({ ...image, dockerImageId: img.Id }); - onFinish(true); - return; + success = true; } catch (e) { if (!NotFoundError(e)) { if (!(e instanceof ImageDownloadBackoffError)) {