fix(account): avoid duplicated accounts + remove existing duplicates - #6559
Open
mahibi wants to merge 2 commits into
Open
fix(account): avoid duplicated accounts + remove existing duplicates#6559mahibi wants to merge 2 commits into
mahibi wants to merge 2 commits into
Conversation
Contributor
|
APK file: https://github.com/nextcloud/talk-android/actions/runs/32744036675/artifacts/9527172309 |
AccountVerificationActivity kicked off its login-verification network chain (capabilities -> profile -> storeProfile) from onResume(), which fires again any time the activity is resumed (e.g. a screen lock/unlock) while verification is still in flight. Each re-entry ran the whole chain again and inserted another User row with the same username/baseUrl/token, since storeProfile() always creates a new row and never checks for an existing match. Move the verification trigger into onCreate(), which runs exactly once per activity instance, so a resume mid-verification no longer restarts the flow. To reproduce: 1. Remove any existing account for the test user so the local DB has no matching User row. 2. Start "Add account" and log in normally; this lands on AccountVerificationActivity and shows "Verifying account..." while it makes several sequential network calls. 3. While that screen is still showing, lock and unlock the screen a couple of times in quick succession (e.g. `adb shell input keyevent KEYCODE_POWER` twice, repeated) to force onResume() to fire again mid-verification. 4. Once login completes, inspect the local User table (e.g. via `adb exec-out run-as <pkg> cat databases/nextcloud_talk.sqlite` and sqlcipher) - before this fix, one extra row appears per resume that landed during verification, all sharing the same username/baseUrl/ token. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Marcel Hibbe <dev@mhibbe.de> Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Add UserManager.scheduleDuplicateAccountsForDeletion(): for each set of local User rows sharing the same username+baseUrl, keep the current account if present, otherwise the oldest row, and schedule the rest for deletion. AccountRemovalWorker now runs this check before its existing removal pass, so duplicates are fully cleaned up (push unregistration, shortcuts, arbitrary storage, WebSocket instance, DB row) through the same path as any other account removal, and before WebsocketConnectionsWorker would otherwise open a parallel signaling connection per duplicate. Logs a warning via the file-backed Logger when duplicates are found, so it's visible without the user needing to have enabled logging beforehand. Add UserManagerTest covering: keeping the current vs. oldest row, groups of three or more duplicates, multiple independent duplicate groups in one pass, rows with a null/blank username or baseUrl never being grouped, and the no-duplicates/no-users no-op cases. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
mahibi
force-pushed
the
bugfix/noid/fixDuplicateAccounts
branch
from
August 24, 2026 17:36
1aaaaf7 to
ba4eba5
Compare
Contributor
|
APK file: https://github.com/nextcloud/talk-android/actions/runs/32757600969/artifacts/9531703020 |
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.
This PR will
AccountVerificationActivity kicked off its login-verification network chain (capabilities -> profile -> storeProfile) from onResume(), which fires again any time the activity is resumed (e.g. a screen lock/unlock) while verification is still in flight. Each re-entry ran the whole chain again and inserted another User row with the same username/baseUrl/token, since storeProfile() always creates a new row and never checks for an existing match.
Move the verification trigger into onCreate(), which runs exactly once per activity instance, so a resume mid-verification no longer restarts the flow.
To reproduce:
adb shell input keyevent KEYCODE_POWERtwice, repeated) to force onResume() to fire again mid-verification.adb exec-out run-as <pkg> cat databases/nextcloud_talk.sqliteand sqlcipher) - before this fix, one extra row appears per resume that landed during verification, all sharing the same username/baseUrl/ token.Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Marcel Hibbe dev@mhibbe.de
馃弫 Checklist
/backport to stable-xx.x馃 AI (if applicable)