Fix Contacts: read iCloud-source DB, support full-name search - #1
Open
bfeeny wants to merge 1 commit into
Open
Conversation
Two related fixes for Apple Contacts on iCloud-using Macs. 1. resolveContactsDB() only read the top-level AddressBook-v22.abcddb, which is the "On My Mac" store and is empty for users whose contacts are synced via iCloud. iCloud contacts live in per-source databases under AddressBook/Sources/<UUID>/AddressBook-v22.abcddb. The previous code returned 0 results with no error, since the top-level file exists but contains no records. This patch scans the AddressBook tree (top-level + every Sources/<UUID>/) and selects the largest .abcddb as the contacts DB. 2. handleSearch's SQL ran each LIKE clause against a single field, so a query like "Julie Thompson" never matched a contact whose first name is "Julie" and last name is "Thompson". Added an additional clause matching against (COALESCE(first_name,'') || ' ' || COALESCE(last_name,'')) so multi-token full-name queries work. Tested on macOS Sonoma with a ~2,300-contact iCloud library: - Before: 0 contacts visible, all searches returned []. - After: full search works; "Julie Thompson" finds the right record.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes for Apple Contacts on macOS where contacts are stored in iCloud.
1.
resolveContactsDB()only reads the top-levelAddressBook-v22.abcddbThe top-level file is the "On My Mac" store and is empty for users whose contacts are synced via iCloud. iCloud-synced contacts live in per-source databases under:
The previous code returned an empty result set with no error, since the top-level file exists but contains no records. Net effect for iCloud users: every Contacts tool returned
[]ortotal_contacts: 0.This patch scans the AddressBook tree (top-level + every
Sources/<UUID>/) and selects the largest.abcddbas the contacts DB. For typical iCloud-only users this picks the right DB on first try.Caveat: users with multiple active sources (iCloud + CardDAV + Exchange, etc.) will only see contacts from the largest DB. Full multi-source support would require querying every DB and unioning/deduping; happy to follow up with that if there's interest.
2. Search SQL doesn't match across
first_name + last_nameEach
LIKEclause matches a single field independently, so a query like"Julie Thompson"misses contacts whose first name is"Julie"and last name is"Thompson". Added an additional clause matching against the concatenated full name:Testing
Tested on macOS Sonoma with a ~2,300-contact iCloud library:
apple_contacts_statsreturnedtotal_contacts: 0; all searches returned[].apple_contacts_search "Julie Thompson"returns the right record; single-token searches continue to work.The startup log line
Using contacts DB: <path> (<size> bytes)makes it easy to verify which DB was selected.