mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Download at the next join when the controller did not store an upload
The controller gave an upload it did not store the same empty reply as one it stored, and the instance confirmed either to the save. An instance restarting after a crash uploads the players it had online, and when another instance had since uploaded the same generation the save took its own copy for the stored one: the next join kept it, and the leave after that stored it over the newer data. The reply now says whether the upload was stored. One that was not marks the save's copy outdated, so it is not uploaded again and the next join downloads. Fixes #1218 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JyNnVzRW4jPWaoWTxCyhM7
This commit is contained in:
1 parent
635b10a3dc
commit
b6bc118297
7 files changed
+84
-6
No files matched your search
@@ -200,11 +200,12 @@ export default async function(context: InstancePluginContext) {
|
||||
delete player_data.destination_instance_id;
|
||||
|
||||
logger.verbose(`Uploading ${player_data.name} (${JSON.stringify(player_data).length / 1000}kB)`);
|
||||
let stored: boolean;
|
||||
try {
|
||||
await instance.sendTo(
|
||||
({ stored } = await instance.sendTo(
|
||||
"controller",
|
||||
new UploadRequest(instance.id, player_data.name, player_data, destinationInstanceId),
|
||||
);
|
||||
));
|
||||
|
||||
} catch (err: any) {
|
||||
if (!(err instanceof lib.SessionLost)) {
|
||||
@@ -213,8 +214,10 @@ export default async function(context: InstancePluginContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A copy the controller did not store must not pass for the stored one: the save downloads at the next join
|
||||
const reply = stored ? "confirm_upload" : "reject_upload";
|
||||
await instance.sendRcon(
|
||||
`/sc player_sync.confirm_upload("${player_data.name}", ${player_data.generation})`, true, plugin.name
|
||||
`/sc player_sync.${reply}("${player_data.name}", ${player_data.generation})`, true, plugin.name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user