Skip to content

Commit 8d18bf0

Browse files
wesmclaude
andcommitted
Fix shared-identifier issues in verify and re-auth hint
1. verify: use findGmailSource() instead of GetSourceByIdentifier() to avoid counting the wrong archive when Gmail and mbox/imap sources share the same identifier. 2. re-auth hint: include --type gmail in the remove-account suggestion since the identifier may be shared across source types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cfdfbc4 commit 8d18bf0

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

cmd/msgvault/cmd/addaccount.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,23 @@ Examples:
143143
},
144144
}
145145

146-
func hasGmailSource(s *store.Store, email string) bool {
146+
func findGmailSource(
147+
s *store.Store, email string,
148+
) *store.Source {
147149
sources, err := s.GetSourcesByIdentifier(email)
148150
if err != nil {
149-
return false
151+
return nil
150152
}
151153
for _, src := range sources {
152154
if src.SourceType == "gmail" {
153-
return true
155+
return src
154156
}
155157
}
156-
return false
158+
return nil
159+
}
160+
161+
func hasGmailSource(s *store.Store, email string) bool {
162+
return findGmailSource(s, email) != nil
157163
}
158164

159165
func init() {

cmd/msgvault/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func getTokenSourceWithReauth(
217217
"re-authorize %s: %w\n"+
218218
"If this account uses an alias, remove "+
219219
"and re-add with the primary address:\n"+
220-
" msgvault remove-account %s\n"+
220+
" msgvault remove-account %s --type gmail\n"+
221221
" msgvault add-account %s",
222222
email, authErr,
223223
mismatch.Expected, mismatch.Actual,

cmd/msgvault/cmd/verify.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,14 @@ Examples:
8787

8888
fmt.Printf("Verifying archive for %s...\n\n", profile.EmailAddress)
8989

90-
// Look up the source by the user-supplied identifier, not the
91-
// canonical profile address — the source is keyed under the
92-
// identifier used during add-account (e.g. first.last@gmail.com
93-
// even if Gmail's canonical form is firstlast@gmail.com).
94-
source, err := s.GetSourceByIdentifier(email)
95-
if err != nil {
96-
return fmt.Errorf("get source: %w", err)
97-
}
90+
// Look up the Gmail source by the user-supplied identifier,
91+
// not the canonical profile address — the source is keyed
92+
// under the identifier from add-account. Filter to Gmail
93+
// specifically since the same identifier may exist for
94+
// other source types (mbox, imap).
95+
source := findGmailSource(s, email)
9896
if source == nil {
99-
fmt.Printf("Account %s not found in database.\n", email)
97+
fmt.Printf("Gmail account %s not found in database.\n", email)
10098
fmt.Println("Run 'sync-full' first to populate the archive.")
10199
return nil
102100
}

0 commit comments

Comments
 (0)