mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 17:16:16 +00:00
When handleDiscoveredDevice calls MoveDevice and the target device directory already exists (pre-existing duplicate state), os.Rename fails with ENOTEMPTY/EEXIST leaving the stale source account entry on disk. Because SaveDeviceInfo has just written fresh data under accountID, it is safe to unconditionally remove the stale source entry afterward — RemoveDevice returns nil when the path is already gone (successful rename), so this is a no-op in the happy path and a cleanup in the failure path. Adds TestHandleDiscoveredDevice_CrossAccountMigration_TargetExists which seeds a device under two real accounts (old sorts alphabetically first so findExistingDeviceInfoByDeviceID picks it as storedAccount), triggers discovery with the new account as MargeAccountUUID, and asserts that after the cycle only the new account entry exists. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>