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 {
|
||||
|
||||
Reference in New Issue
Block a user