item_updater: Ignore duplicate version ids

If the partitions or devices where the BMC images reside are
flashed with the same image file, for example during manufacturing
process, we'd end up with duplicate version ids. Ignore that
version for now and treat it as non-existent. A subsequent code
update would rewrite that partition.

There is a request about being able to support an Accept/Commit
operation which would write the current version to the other
BMC versions, so that for example a system with versions that
contain a security vulnerability can be updated to the fixed
version but also overwrite any other old versions to prevent the
system from booting from an old version. So eventually we'll
add support to show the system with 2 BMC versions that are the
same.

Tested: Flashed an eMMC with the same image on both BMC partitions
        and verified only one d-bus object was created and the
        software updater didn't crash.

Change-Id: I95c5ed968df074ff56da3f80c07a95505fbdf2cd
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 3ee85b2..8b860b5 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -211,6 +211,14 @@
 
             auto id = VersionClass::getId(version);
 
+            // Check if the id has already been added. This can happen if the
+            // BMC partitions / devices were manually flashed with the same
+            // image.
+            if (versions.find(id) != versions.end())
+            {
+                continue;
+            }
+
             auto purpose = server::Version::VersionPurpose::BMC;
             restorePurpose(id, purpose);