From 7c1ec3081a5487c9f83a74c64afaa85f3d6921ae Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 26 May 2023 09:59:05 -0400 Subject: [PATCH] When using additional stores, report id only once Currently if you setup additional stores and pull the same image that exists in additionalstore, podman ends up reporting the ID twice. Fixes: https://github.com/containers/podman/issues/18647 Signed-off-by: Daniel J Walsh --- libimage/pull.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libimage/pull.go b/libimage/pull.go index 4a0f5970d..188ecb5ef 100644 --- a/libimage/pull.go +++ b/libimage/pull.go @@ -442,8 +442,17 @@ func (r *Runtime) imagesIDsForManifest(manifestBytes []byte, sys *types.SystemCo if err != nil { return nil, fmt.Errorf("listing images by manifest digest: %w", err) } - results := make([]string, 0, len(images)) + + // If you have additionStores defined and the same image stored in + // both storage and additional store, it can be output twice. + // Fixes github.com/containers/podman/issues/18647 + results := []string{} + imageMap := map[string]bool{} for _, image := range images { + if imageMap[image.ID] { + continue + } + imageMap[image.ID] = true results = append(results, image.ID) } if len(results) == 0 {