Compare commits

...
2 Commits
3 changed files with 28 additions and 8 deletions
+11
View File
@@ -502,6 +502,17 @@
WEEKLY_RSYNC_ENABLED=true # Tier 2 — weekly_sync_maintenance.sh rsync section WEEKLY_RSYNC_ENABLED=true # Tier 2 — weekly_sync_maintenance.sh rsync section
FALLBACK_RSYNC_ENABLED=true # Tier 2 — fallback.sh writeback jobs on handback FALLBACK_RSYNC_ENABLED=true # Tier 2 — fallback.sh writeback jobs on handback
# ━━━ Download Webhook ━━━
# Immediate push to remote nodes on every Sonarr/Radarr/Lidarr Download event.
# Prevents remotes from searching for content that is already on disk locally.
DOWNLOAD_WEBHOOK_ENABLED=true
# ━━━ Rsync Merge Auto-Promote ━━━
# When enabled, rsync.sh pre-scans the remote before syncing and promotes to merge
# mode (pull-then-push) if ≥75% of remote top-level entries exist locally.
# Named profiles are always excluded from auto-promote regardless of this toggle.
RSYNC_MERGE_ENABLED=true
# ━━━ Rsync Defaults ━━━ # ━━━ Rsync Defaults ━━━
# Global fallback values used when no profile match is found. # Global fallback values used when no profile match is found.
# Media shares in HOST*_DAILY_SYNC_SHARES always use these globals — no profile needed. # Media shares in HOST*_DAILY_SYNC_SHARES always use these globals — no profile needed.
+12 -6
View File
@@ -1,5 +1,5 @@
<?php <?php
// Receives Sonarr/Radarr/Lidarr OnUpgrade events. Fires upgrade_webhook_handler.sh // Receives Sonarr/Radarr/Lidarr Download events. Fires upgrade_webhook_handler.sh
// in the background and returns 200 immediately — arr does not wait on the push. // in the background and returns 200 immediately — arr does not wait on the push.
header('Content-Type: application/json'); header('Content-Type: application/json');
require_once dirname(__DIR__) . '/include/config.php'; require_once dirname(__DIR__) . '/include/config.php';
@@ -20,14 +20,20 @@ if (!$payload) {
$event = $payload['eventType'] ?? ''; $event = $payload['eventType'] ?? '';
if ($event === 'Test') { if ($event === 'Test') {
echo json_encode(['ok' => true, 'message' => 'Webhook connected — configure On Upgrade to use this URL']); echo json_encode(['ok' => true, 'message' => 'Webhook connected — configure On Download to use this URL']);
exit; exit;
} }
// Sonarr/Radarr/Lidarr fire eventType "Download" with isUpgrade=true for upgrades. $vars = vv_conf_vars();
// A plain Download (no upgrade) is not our concern — the original quality is fine. $enabled = strtolower($vars['DOWNLOAD_WEBHOOK_ENABLED'] ?? 'true') !== 'false';
$is_upgrade = $payload['isUpgrade'] ?? false; if (!$enabled) {
if ($event !== 'Download' || !$is_upgrade) { echo json_encode(['ok' => true, 'skipped' => 'DOWNLOAD_WEBHOOK_ENABLED=false']);
exit;
}
// Fire on any Download event — new grabs and upgrades both need immediate propagation
// so remote nodes don't search for something we already have.
if ($event !== 'Download') {
echo json_encode(['ok' => true, 'skipped' => $event]); echo json_encode(['ok' => true, 'skipped' => $event]);
exit; exit;
} }
+5 -2
View File
@@ -271,8 +271,11 @@ check_remote_disks "$DIRECTORY"
# ── Merge-run pre-scan ──────────────────────────────────────────────────────────────────────── # ── Merge-run pre-scan ────────────────────────────────────────────────────────────────────────
# Auto-promote to merge mode when ≥75% of remote's top-level entries exist locally. # Auto-promote to merge mode when ≥75% of remote's top-level entries exist locally.
# Skipped when --merge-run is already set or --seed is active (remote was just created). # Skipped when: --merge-run is already set, --seed is active, a named profile is resolved,
if [[ "$MERGE_RUN" == false && "$SEED" == false ]]; then # or RSYNC_MERGE_ENABLED=false in master.conf.
if [[ "$MERGE_RUN" == false && "$SEED" == false \
&& "${RSYNC_MERGE_ENABLED:-true}" != "false" \
&& -z "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]+x}" ]]; then
_remote_top=$(ssh -i "$SSH_KEY" -o ConnectTimeout=10 -o BatchMode=yes \ _remote_top=$(ssh -i "$SSH_KEY" -o ConnectTimeout=10 -o BatchMode=yes \
root@"$REMOTE_SERVER" "ls -1A '$DIRECTORY' 2>/dev/null | sort" 2>/dev/null) root@"$REMOTE_SERVER" "ls -1A '$DIRECTORY' 2>/dev/null | sort" 2>/dev/null)
_remote_count=$(echo "$_remote_top" | grep -c . 2>/dev/null || echo 0) _remote_count=$(echo "$_remote_top" | grep -c . 2>/dev/null || echo 0)