From 0149c72639bcf6c6cf324c74a512b0f1989b8be1 Mon Sep 17 00:00:00 2001 From: ILLISIS Date: Tue, 20 Oct 2026 13:19:29 +1100 Subject: [PATCH] Upload on leave while an unconfirmed prefetched copy is held The leave handler skipped the upload for any active download, including a prefetched copy no join had confirmed, which has replaced nothing here. Newer local data, such as after a failed upload whose retry the join cleared, was then never uploaded. Only a real download skips it now; a copy whose join took the body still uploads nothing through sync_in_progress. Co-Authored-By: Claude Opus 5.5 (1M context) --- plugins/player_sync/module/player_sync.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/player_sync/module/player_sync.lua b/plugins/player_sync/module/player_sync.lua index 4a02932c..a54d2633 100644 --- a/plugins/player_sync/module/player_sync.lua +++ b/plugins/player_sync/module/player_sync.lua @@ -583,10 +583,15 @@ player_sync.events[defines.events.on_pre_player_left_game] = function(event) local destination = player_record.destination player_record.destination = nil - -- If player has an active download release our acquisition but let the download continue - if script_data.active_downloads[player.name] then - -- A prefetched copy is confirmed per join: the next join's acquire reply confirms it again - script_data.active_downloads[player.name].confirmed = nil + local download = script_data.active_downloads[player.name] + if download and download.prefetch then + -- A prefetched copy is confirmed per join: the next join's acquire reply confirms it again. Until then it has + -- replaced nothing here, so the checks below decide the upload. One whose join took the body (spectate) left + -- sync_in_progress set, and uploads nothing. + download.confirmed = nil + + elseif download then + -- If player has an active download release our acquisition but let the download continue clusterio_api.send_json("player_sync_release", { player_name = player.name }) return end