Media build part 2 (unreleased): drive wiring in every app (R-1024/R-1037), old-install repair (R-1047), drive events notice + real restart now/later + stream check, file browser lets go of dead/removed drives and recreates on return (R-1038), safe removal keeps the drive (R-1044), Plex claim on the running server + probe accept (R-1028/R-1045)
gates / gates (push) Successful in 45s

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-10-15 09:54:49 +02:00
1 parent 78c894234c
commit f580d88a14
46 files changed
+3700 -8

No files matched your search

@@ -315,6 +315,7 @@ func (s *Server) registerStoragePath(where, label string, setDefault bool) error
return util.MsgError("err.web.regisztracio_sikertelen", err)
}
go s.SyncFileBrowserMounts()
s.mediaDriveEvent(where, "added") // R-1023: the media apps see it after a restart
return nil
}
@@ -370,6 +371,9 @@ func (s *Server) storageWizardPageHandler(w http.ResponseWriter, r *http.Request
// ServeStorageAPI dispatches /api/storage/* (guided init/attach/eject orchestration).
func (s *Server) ServeStorageAPI(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/api/storage/media/") && s.ServeMediaAPI(w, r) {
return
}
switch {
case r.URL.Path == "/api/storage/init" && r.Method == http.MethodPost:
s.handleStorageInit(w, r)
@@ -983,12 +987,35 @@ func (s *Server) handleStorageEject(w http.ResponseWriter, r *http.Request) {
writeDiskJSON(w, http.StatusServiceUnavailable, false, s.errText(r, err), nil)
return
}
// R-1044 (v0.313.0): with media apps on the box, a safe removal FIRST lets go of the drive — pause only its torrents,
// recreate the media apps and the file browser without it — and KEEPS it registered (removed), so its return needs no
// household step. Measured 2026-10-14 (K3-3): the old eject left running apps holding the filesystem and forgot the
// drive („Meglévő meghajtó csatolása" after every return).
mediaRemoval := len(s.mediaApps()) > 0 && strings.HasPrefix(req.Where, StableParentDir+"/")
if mediaRemoval {
durable := ""
if dr, derr := agent.Disks(r.Context()); derr == nil {
durable = ejectDurableID(dr.Disks, req.Where)
}
s.mediaSafeRemoval(req.Where, durable)
s.mediaDriveEvent(req.Where, "removed")
}
// The registered path is the STABLE /mnt/felhom-drives/<name>; the agent operates on the raw mount.
res, err := agent.EjectDisk(r.Context(), agentWhere(req.Where))
if err != nil {
if mediaRemoval {
// The unmount did not happen: the drive is still here — undo the removal mark so the apps get it back.
_ = s.settings.ClearEjected(req.Where)
s.mediaDriveEvent(req.Where, "returned")
}
writeDiskJSON(w, http.StatusBadGateway, false, s.errText(r, err), nil)
return
}
if mediaRemoval {
s.logger.Printf("[INFO] [web] eject: %s safely removed and KEPT registered (media apps on the box, R-1044)", req.Where)
writeDiskJSON(w, http.StatusOK, true, "", res)
return
}
// Deregister the path (best-effort — the unmount already succeeded).
if rerr := s.settings.RemoveStoragePath(req.Where); rerr != nil {
s.logger.Printf("[WARN] [web] eject: unmounted %s but deregister failed: %v", req.Where, rerr)