Skip to content

Commit 43e9a77

Browse files
jared mauchjared mauch
authored andcommitted
Improve duplicate list detection in password upgrade check
- Deduplicate listnames list before processing - Track both listname and internal_name to catch all duplicate cases - Use real_name for display instead of internal_name for better readability - Add multiple levels of deduplication to ensure each list appears only once This fixes an issue where the same list could appear multiple times in the output with different email addresses.
1 parent a16da9c commit 43e9a77

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

bin/update

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,24 +683,32 @@ def check_and_notify_password_upgrades(dry_run=False):
683683

684684
print('Checking for lists with old password formats...')
685685
lists_needing_upgrade = []
686-
seen_lists = {} # Track by internal name to avoid duplicates
686+
seen_listnames = set() # Track by listname to avoid duplicates
687+
seen_internal_names = set() # Track by internal name to avoid duplicates
687688

688689
# Check all lists for old password formats
689-
listnames = Utils.list_names()
690+
# Deduplicate listnames first to avoid processing the same list multiple times
691+
listnames = list(dict.fromkeys(Utils.list_names())) # Preserves order, removes duplicates
690692
for listname in listnames:
693+
# Skip if we've already seen this listname
694+
if listname in seen_listnames:
695+
continue
696+
seen_listnames.add(listname)
697+
691698
try:
692699
mlist = MailList.MailList(listname, lock=0)
693700
except Exception as e:
694701
print(C_('Warning: Could not check list %(listname)s: %(e)s') % {
695702
'listname': listname, 'e': e})
696703
continue
697704

698-
# Use internal_name() as key to avoid processing the same list twice
705+
# Also check by internal_name() to catch cases where different listnames
706+
# map to the same internal list
699707
internal_name = mlist.internal_name()
700-
if internal_name in seen_lists:
701-
# Already processed this list, skip
708+
if internal_name in seen_internal_names:
709+
# Already processed this list (by internal name), skip
702710
continue
703-
seen_lists[internal_name] = True
711+
seen_internal_names.add(internal_name)
704712

705713
needs_upgrade = False
706714
# Check list admin password
@@ -738,8 +746,10 @@ def check_and_notify_password_upgrades(dry_run=False):
738746
print(C_('DRY-RUN: Would send password upgrade notifications to %(count)d list(s).') % {
739747
'count': len(lists_needing_upgrade)})
740748
for mlist in lists_needing_upgrade:
749+
# Use real_name for display, fallback to internal_name if real_name is not set
750+
display_name = mlist.real_name or mlist.internal_name()
741751
print(C_(' - Would notify owners of %(listname)s (%(listaddr)s)') % {
742-
'listname': mlist.internal_name(),
752+
'listname': display_name,
743753
'listaddr': mlist.GetListEmail()})
744754
else:
745755
for mlist in lists_needing_upgrade:

0 commit comments

Comments
 (0)