- bool duplicate_found = false;
- bool found = false;
- do {
- var cards = this.store.get_card_list();
- found = false;
- foreach (IdCard id_card in cards) {
- if ((new_card != id_card) && (id_card.nai == new_card.nai)) {
- stdout.printf("removing duplicate id for '%s'\n", new_card.nai);
- logger.trace("removing duplicate id for '%s'\n".printf(new_card.nai));
- remove_card_internal(id_card);
- found = duplicate_found = true;
-
- if (new_card.trust_anchor.Compare(id_card.trust_anchor) == 0) {
- logger.trace("Old and new cards have same trust anchor. Re-using the datetime_added and user_verified fields from the old card.");
- new_card.trust_anchor.set_datetime_added(id_card.trust_anchor.datetime_added);
- new_card.trust_anchor.user_verified = id_card.trust_anchor.user_verified;
- }
- break;
- }
+ ArrayList<IdCard> dups = new ArrayList<IdCard>();
+ var cards = this.store.get_card_list();
+ foreach (IdCard id_card in cards) {
+ if ((new_card != id_card) && (id_card.nai == new_card.nai)) {
+ dups.add(id_card);
+ }
+ }
+
+ foreach (IdCard id_card in dups) {
+ logger.trace("removing duplicate id for '%s'\n".printf(new_card.nai));
+ remove_card_internal(id_card);
+
+ if (new_card.trust_anchor.Compare(id_card.trust_anchor) == 0) {
+ logger.trace("Old and new cards have same trust anchor. Re-using the datetime_added and user_verified fields from the old card.");
+ new_card.trust_anchor.set_datetime_added(id_card.trust_anchor.datetime_added);
+ new_card.trust_anchor.user_verified = id_card.trust_anchor.user_verified;