Use one build number across phone, Mac and Status

This commit is contained in:
Ian Gulliver
2026-10-22 07:19:28 -07:00
parent 9952170aae
commit e1eeaad925
14 changed files with 377 additions and 368 deletions
+10 -8
View File
@@ -33,6 +33,7 @@ type Client struct {
Login string
Host string
Commit string
Build string
Device string
ConnectedAt time.Time
LastActionAt *time.Time
@@ -70,7 +71,7 @@ func New(changed func()) *Registry {
return &Registry{clients: map[string]*entry{}, transfers: map[string]Transfer{}, changed: changed}
}
func (r *Registry) entry(id, login, host, commit string, now time.Time) *entry {
func (r *Registry) entry(id, login, host, commit, build string, now time.Time) *entry {
for k, e := range r.clients {
if e.conn == nil && now.Sub(e.seen) > expireAfter {
delete(r.clients, k)
@@ -84,18 +85,19 @@ func (r *Registry) entry(id, login, host, commit string, now time.Time) *entry {
e.Login = login
e.Host = host
e.Commit = commit
e.Build = build
e.seen = now
return e
}
func (r *Registry) Acted(id, login, host, commit string) bool {
func (r *Registry) Acted(id, login, host, commit, build string) bool {
if id == "" {
return false
}
r.mu.Lock()
defer r.mu.Unlock()
now := time.Now()
e := r.entry(id, login, host, commit, now)
e := r.entry(id, login, host, commit, build, now)
e.LastActionAt = &now
if now.Sub(e.notified) < time.Second {
return false
@@ -104,19 +106,19 @@ func (r *Registry) Acted(id, login, host, commit string) bool {
return true
}
func (r *Registry) Synced(id, login, host, commit string, sync api.ClientSync) {
func (r *Registry) Synced(id, login, host, commit, build string, sync api.ClientSync) {
r.mu.Lock()
defer r.mu.Unlock()
r.entry(id, login, host, commit, time.Now()).Sync = &sync
r.entry(id, login, host, commit, build, time.Now()).Sync = &sync
}
func (r *Registry) Serve(ctx context.Context, ws *websocket.Conn, id, login, host, commit, device string) {
func (r *Registry) Serve(ctx context.Context, ws *websocket.Conn, id, login, host, commit, build, device string) {
ws.SetReadLimit(readLimit)
c := &conn{ws: ws, done: make(chan struct{}), pending: map[string]chan api.ClientReply{}}
r.mu.Lock()
now := time.Now().UTC()
e := r.entry(id, login, host, commit, now)
e := r.entry(id, login, host, commit, build, now)
old := e.conn
e.conn = c
e.Device = device
@@ -125,7 +127,7 @@ func (r *Registry) Serve(ctx context.Context, ws *websocket.Conn, id, login, hos
if old != nil {
old.ws.Close(websocket.StatusGoingAway, "replaced by a newer connection from this client")
}
slog.Info("client connected", "id", id, "host", host, "device", device, "login", login, "commit", commit)
slog.Info("client connected", "id", id, "host", host, "device", device, "login", login, "build", build, "commit", commit)
r.changed()
defer func() {