Fix original plugin base config object being mutated when updating config

This commit is contained in:
Tulir Asokan 2019-08-30 01:27:58 +03:00
parent eb353c4964
commit cbe312176d

View File

@ -167,7 +167,12 @@ class PluginInstance:
self.base_cfg = RecursiveDict(yaml.load(base.decode("utf-8")), CommentedMap) self.base_cfg = RecursiveDict(yaml.load(base.decode("utf-8")), CommentedMap)
except (FileNotFoundError, KeyError): except (FileNotFoundError, KeyError):
self.base_cfg = None self.base_cfg = None
self.config = config_class(self.load_config, lambda: self.base_cfg, self.save_config) if self.base_cfg:
base_cfg_func = self.base_cfg.clone
else:
def base_cfg_func() -> None:
return None
self.config = config_class(self.load_config, base_cfg_func, self.save_config)
self.plugin = cls(client=self.client.client, loop=self.loop, http=self.client.http_client, self.plugin = cls(client=self.client.client, loop=self.loop, http=self.client.http_client,
instance_id=self.id, log=self.log, config=self.config, instance_id=self.id, log=self.log, config=self.config,
database=self.inst_db, webapp=self.inst_webapp, database=self.inst_db, webapp=self.inst_webapp,