mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Fix setting instance config fields not being saved
If only the config of an instance is updated the dirty flag of the instance is not set, which results in changes being discarded when the controller shuts down afterwards. Fix by always triggering the update logic when an instance field is changed.
This commit is contained in:
1 parent
300db5cbfd
commit
34da073800
2 files changed
+12
-4
No files matched your search
@@ -924,9 +924,7 @@ export default class Controller {
|
||||
addInstanceHooks(instance: InstanceInfo) {
|
||||
instance.config.on("fieldChanged", (field: string, curr: any, prev: any) => {
|
||||
instance.updatedAtMs = Date.now();
|
||||
if (field === "instance.name") {
|
||||
this.instances.set(instance); // Trigger updated logic
|
||||
}
|
||||
this.instances.set(instance); // Trigger update logic
|
||||
|
||||
lib.invokeHook(this.plugins, "onInstanceConfigFieldChanged", instance, field, curr, prev);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,9 @@ class MockInstanceConfig extends EventEmitter {
|
||||
}
|
||||
|
||||
set(field, value) {
|
||||
return this._data.set(field, value);
|
||||
const prev = this.get(field);
|
||||
this._data.set(field, value);
|
||||
this.emit("fieldChanged", field, value, prev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,5 +181,13 @@ describe("controller/src/Controller", function() {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe(".instances", function() {
|
||||
it("should set the dirty flag if the config is updated", function() {
|
||||
controller.instances.dirty = false;
|
||||
mockInstanceConfig.set("instance.assigned_host", null);
|
||||
assert(controller.instances.dirty === true, "dirty flag was not set");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user