Plex (R-1045): the controller asks Plex itself whether it is claimed — after the claim and on the household's „Kész”; no template probe (an older controller would refuse the press forever)
gates / gates (push) Successful in 45s
gates / gates (push) Successful in 45s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -385,7 +385,7 @@ func (s *Server) appPlexClaimHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
for i := 0; i < 10; i++ {
|
||||
if has, done, _, perr := s.stackMgr.SetupGateProbe("plex"); has && perr == nil && done {
|
||||
if plexClaimed() {
|
||||
if oerr := s.stackMgr.OpenSetupGate("plex", stacks.SetupGateByProbe); oerr != nil && !errors.Is(oerr, stacks.ErrSetupGateNotClosed) {
|
||||
s.logger.Printf("[WARN] [web] plex: claimed, but opening the setup gate failed: %v", oerr)
|
||||
}
|
||||
@@ -442,3 +442,25 @@ func ejectStep(sp settings.StoragePath, disks []agentapi.DiskInfo) (int, *agenta
|
||||
}
|
||||
return ejectBack, disk
|
||||
}
|
||||
|
||||
// plexClaimed asks the running Plex itself whether it is claimed (`/identity`, JSON only with this Accept header —
|
||||
// measured 2026-10-15). A seam for tests. The live template carries NO setup_done_probe on purpose: a controller older
|
||||
// than 0.313.0 would send no Accept header, read XML as „not JSON" and refuse the household's „Kész" forever.
|
||||
var plexClaimed = func() bool {
|
||||
req, err := http.NewRequest(http.MethodGet, "http://plex:32400/identity", nil)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
resp, err := (&http.Client{Timeout: 5 * time.Second}).Do(req)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var id struct {
|
||||
MediaContainer struct {
|
||||
Claimed bool `json:"claimed"`
|
||||
} `json:"MediaContainer"`
|
||||
}
|
||||
return resp.StatusCode == http.StatusOK && json.NewDecoder(resp.Body).Decode(&id) == nil && id.MediaContainer.Claimed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user