From 2b50ef0c988bf5b27c4e0397d2380fc1b72880cd Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Wed, 20 May 2026 22:37:57 +0200 Subject: [PATCH] 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 --- pkg/service/datastore/datastore.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/service/datastore/datastore.go b/pkg/service/datastore/datastore.go index 44238e1..cffef90 100644 --- a/pkg/service/datastore/datastore.go +++ b/pkg/service/datastore/datastore.go @@ -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 }