mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 07:24:53 +09:00
Keep accepting uploads from instances without epochs
A host running the plugin from before epochs never sends one, so after an import or delete every upload it made was discarded while the instance believed it succeeded. The Lua now always sends its epoch, and an upload without one is compared by generation against the stored data the way it was before, taking over the stored epoch. Those hosts can still overwrite an import with a copy they failed to upload, which the README now says. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2529683c2b
commit
5634651de1
5 files changed
+48
-5
No files matched your search
@@ -93,7 +93,7 @@ describe("player_sync controller", function() {
|
||||
|
||||
describe("player data tools", function() {
|
||||
function playerData(name, generation, extra = {}) {
|
||||
return { generation, name, controller: "character", force: "player", ...extra };
|
||||
return { generation, epoch: 0, name, controller: "character", force: "player", ...extra };
|
||||
}
|
||||
|
||||
let controller;
|
||||
@@ -251,7 +251,37 @@ describe("player_sync controller", function() {
|
||||
});
|
||||
it("should reject when the player is acquired", async function() {
|
||||
await assert.rejects(del("stored"), acquiredError);
|
||||
assert((await saved()).has("stored"));
|
||||
assert.deepEqual((await saved()).get("stored"), playerData("stored", 3));
|
||||
});
|
||||
});
|
||||
|
||||
describe("uploads without an epoch", function() {
|
||||
// What instances running a version from before epochs send
|
||||
function legacyData(generation) {
|
||||
const data = playerData("stored", generation);
|
||||
delete data.epoch;
|
||||
return data;
|
||||
}
|
||||
beforeEach(async function() {
|
||||
await handler(msg.ForceReleaseRequest)(new msg.ForceReleaseRequest("stored"));
|
||||
});
|
||||
it("should store them by generation", async function() {
|
||||
await upload(1, legacyData(3));
|
||||
await upload(1, legacyData(4));
|
||||
assert.deepEqual((await saved()).get("stored"), legacyData(4));
|
||||
});
|
||||
it("should keep accepting them after an import", async function() {
|
||||
const request = new msg.SetPlayerDataRequest("stored", playerData("stored", 0));
|
||||
await handler(msg.SetPlayerDataRequest)(request);
|
||||
await upload(1, legacyData(4));
|
||||
assert.equal((await saved()).get("stored").epoch, 1);
|
||||
await upload(1, legacyData(5));
|
||||
assert.deepEqual((await saved()).get("stored"), playerData("stored", 5, { epoch: 1 }));
|
||||
});
|
||||
it("should accept any generation after a delete", async function() {
|
||||
await handler(msg.DeletePlayerDataRequest)(new msg.DeletePlayerDataRequest("stored"));
|
||||
await upload(1, legacyData(1));
|
||||
assert.deepEqual((await saved()).get("stored"), playerData("stored", 1, { epoch: 1 }));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user