diff --git a/service/profile/profile.go b/service/profile/profile.go index 340b77cd..df9f54ab 100644 --- a/service/profile/profile.go +++ b/service/profile/profile.go @@ -538,13 +538,14 @@ func (profile *Profile) updateMetadataFromSystem(ctx context.Context, md Matchin } // Apply new icon if found. - if newIcon != nil { + if newIcon != nil && !profile.iconExists(newIcon) { if len(profile.Icons) == 0 { profile.Icons = []binmeta.Icon{*newIcon} } else { profile.Icons = append(profile.Icons, *newIcon) profile.Icons = binmeta.SortAndCompactIcons(profile.Icons) } + changed = true } }() @@ -559,3 +560,13 @@ func (profile *Profile) updateMetadataFromSystem(ctx context.Context, md Matchin return nil } + +// Checks if the given icon already assigned to the profile. +func (profile *Profile) iconExists(newIcon *binmeta.Icon) bool { + for _, icon := range profile.Icons { + if icon.Value == newIcon.Value && icon.Type == newIcon.Type && icon.Source == newIcon.Source { + return true + } + } + return false +}