Check the CloudKit schema when packaging and show broken iCloud sync
This commit is contained in:
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -12,6 +13,8 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/coder/websocket"
|
||||
|
||||
"g.fc.run/ai/byre/internal/api"
|
||||
)
|
||||
|
||||
func (s *Server) ConnectClient(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -32,6 +35,31 @@ func (s *Server) ConnectClient(w http.ResponseWriter, r *http.Request) {
|
||||
s.clients.Serve(r.Context(), ws, id, actor(r), host, r.Header.Get("Byre-Commit"))
|
||||
}
|
||||
|
||||
func (s *Server) SetClientSync(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.Header.Get("Byre-Client")
|
||||
host := r.Header.Get("Byre-Host")
|
||||
if id == "" || host == "" {
|
||||
writeError(w, http.StatusBadRequest, errors.New("missing Byre-Client or Byre-Host"))
|
||||
return
|
||||
}
|
||||
sync := api.ClientSync{}
|
||||
err := json.NewDecoder(r.Body).Decode(&sync)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
if !sync.Ok {
|
||||
if sync.Error == nil {
|
||||
writeError(w, http.StatusBadRequest, errors.New("a failed sync needs an error"))
|
||||
return
|
||||
}
|
||||
slog.Warn("client icloud sync failing", "id", id, "host", host, "error", *sync.Error)
|
||||
}
|
||||
s.clients.Synced(id, actor(r), host, r.Header.Get("Byre-Commit"), sync)
|
||||
s.clientsChanged()
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (s *Server) GetClientTransfer(w http.ResponseWriter, r *http.Request, transferID string) {
|
||||
t, ok := s.clients.Transfer(transferID)
|
||||
if !ok || t.Receive {
|
||||
|
||||
@@ -165,6 +165,7 @@ func (s *Server) connectedClients() []api.ConnectedClient {
|
||||
Commit: c.Commit,
|
||||
ConnectedAt: c.ConnectedAt,
|
||||
LastActionAt: c.LastActionAt,
|
||||
Sync: c.Sync,
|
||||
})
|
||||
}
|
||||
return out
|
||||
@@ -176,6 +177,7 @@ func (s *Server) clientsChanged() {
|
||||
|
||||
var automaticRequests = map[string]bool{
|
||||
"PUT /api/me/pane-focus": true,
|
||||
"PUT /api/clients/sync": true,
|
||||
"PUT /api/tasks/{taskId}/summary-read": true,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user