From b3c9149aef917d3992a9c0439ba75805486ad268 Mon Sep 17 00:00:00 2001 From: bupd Date: Wed, 3 Jul 2024 06:20:42 +0530 Subject: [PATCH] add err handling Signed-off-by: bupd --- internal/store/in-memory-store.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/store/in-memory-store.go b/internal/store/in-memory-store.go index 9048acb..56b5112 100644 --- a/internal/store/in-memory-store.go +++ b/internal/store/in-memory-store.go @@ -98,7 +98,9 @@ func (s *inMemoryStore) handleFileSource(ctx context.Context, imageList []Image) } } if !found { - s.RemoveImage(ctx, image) + if err := s.RemoveImage(ctx, image); err != nil { + return false, err + } change = true } } @@ -206,8 +208,14 @@ func (s *inMemoryStore) Add(ctx context.Context, digest string, image string) er } } +// Add the image to the store func (s *inMemoryStore) AddImage(ctx context.Context, image string) { - // Add the image to the store + if _, exists := s.images[image]; exists { + fmt.Printf( + "Warning: Image %s already exists in the store. Proceeding with the addition.\n", + image, + ) + } s.images[image] = "" fmt.Printf("Added image: %s\n", image) }