fix(datastore): prefer named default entry when two default dirs collide in ListAllDevices

When the same device appears under `default/` in two separate data dirs
(e.g. primary DataDir and the legacy st-go/data path), the first-seen entry
was kept unconditionally even when it had an empty name. A subsequent
default entry carrying a real name was silently dropped, causing name loss
in SyncFromAccountFull.

Addresses TestReproduceMissingName regression introduced by the
dedup-default-last change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-05-20 22:41:32 +02:00
co-authored by Claude Sonnet 4.6
parent fa2f7cd17d
commit 2b50ef0c98
+7
View File
@@ -681,7 +681,14 @@ func (ds *DataStore) ListAllDevices() ([]models.ServiceDeviceInfo, error) {
}
// "default" never replaces a real-account entry.
// But when two "default" entries collide across data dirs,
// prefer the one with a non-empty name (more information).
if info.AccountID == accountIDDefault {
if entry.account == accountIDDefault && devices[entry.index].Name == "" && info.Name != "" {
devices[entry.index] = info
seenIDs[key] = seenEntry{index: entry.index, account: info.AccountID}
}
continue
}