Fix dropped library sync after startup scan and bump media-node to 1.3.10.

Queue a second full sync when one is already running so newly indexed seasons are not lost after upgrade/restart.
This commit is contained in:
Jos Vooges | STH 2026-09-17 02:07:52 +02:00
parent 075153da8f
commit af1f471b29
6 changed files with 18 additions and 5 deletions

View file

@ -65,7 +65,7 @@ export default function NodesPage() {
const [editRoots, setEditRoots] = useState<ScanRootRow[]>([]);
const [editBusy, setEditBusy] = useState(false);
const [upgradingId, setUpgradingId] = useState<string | null>(null);
const [targetNodeVersion, setTargetNodeVersion] = useState("1.3.9");
const [targetNodeVersion, setTargetNodeVersion] = useState("1.3.10");
function loadNodes() {
fetch("/api/v1/admin/nodes", { credentials: "include" })

View file

@ -1,6 +1,6 @@
/** Target media-node version served from /install/media-node-linux-* */
export const MEDIA_NODE_TARGET_VERSION =
process.env.MEDIA_NODE_VERSION?.trim() || "1.3.9";
process.env.MEDIA_NODE_VERSION?.trim() || "1.3.10";
/** Minimum node version that handles UPGRADE over WebSocket */
const REMOTE_UPGRADE_MIN_VERSION = "1.3.3";

View file

@ -4,7 +4,7 @@ WORKDIR /app
FROM golang:1.22-alpine AS node-build
WORKDIR /src
ARG MEDIA_NODE_VERSION=1.3.9
ARG MEDIA_NODE_VERSION=1.3.10
RUN apk add --no-cache git ca-certificates
COPY node/media-node/ ./
RUN go mod tidy \

View file

@ -74,7 +74,7 @@ mv "$BIN_PATH.new" "$BIN_PATH"
if docker_cmd ps -a --format '{{.Names}}' | grep -qx "$CONTAINER"; then
echo "Container herstarten..."
docker_cmd restart "$CONTAINER" >/dev/null
echo "Klaar. Controleer versie in Admin → Nodes (verwacht ${MEDIA_NODE_VERSION:-1.3.9}+)."
echo "Klaar. Controleer versie in Admin → Nodes (verwacht ${MEDIA_NODE_VERSION:-1.3.10}+)."
else
echo "Waarschuwing: container '$CONTAINER' niet gevonden — binary is wel bijgewerkt."
fi

View file

@ -24,7 +24,7 @@ import (
"github.com/sthmedia/media-node/internal/streaming"
)
var version = "1.3.9"
var version = "1.3.10"
func main() {
if len(os.Args) < 2 {

View file

@ -56,6 +56,7 @@ type Client struct {
stopCh chan struct{}
syncAckCh chan syncAck
fullSyncActive bool
pendingFullSync bool
pendingEvents []scanner.LibraryEvent
eventBatch []scanner.LibraryEvent
eventFlushTimer *time.Timer
@ -146,6 +147,7 @@ func (c *Client) connect() error {
c.conn = conn
c.connected = true
c.fullSyncActive = false
c.pendingFullSync = false
c.pendingEvents = nil
c.mu.Unlock()
@ -894,10 +896,15 @@ func (c *Client) RequestFullLibrarySync() {
func (c *Client) sendFullSync() {
c.mu.Lock()
if c.fullSyncActive {
// Scan-na-connect race: HELLO sync loopt al, startup-scan eindigt later.
// Niet droppen — anders blijven nieuw geïndexeerde files (bijv. S10) op de node.
c.pendingFullSync = true
c.mu.Unlock()
log.Println("Full library sync already running — queued another pass after it finishes")
return
}
c.fullSyncActive = true
c.pendingFullSync = false
c.mu.Unlock()
defer func() {
@ -905,10 +912,16 @@ func (c *Client) sendFullSync() {
c.fullSyncActive = false
pending := c.pendingEvents
c.pendingEvents = nil
rerun := c.pendingFullSync
c.pendingFullSync = false
c.mu.Unlock()
if len(pending) > 0 {
c.flushLibraryEvents(pending)
}
if rerun {
log.Println("Running queued full library sync")
go c.sendFullSync()
}
}()
// Never sync a half-built inventory — Master would prune the rest as missing.