mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Config] Fix unloading and implement singleton driver (#1458)
* Add the identifier as an initialization parameter * Remove config object singleton and opt for a shared JSON datastore * Fix bot unloading to deal with memory leaks * Fix tests * Fix clear all bug
This commit is contained in:
@@ -32,8 +32,8 @@ class Mongo(BaseDriver):
|
||||
"""
|
||||
Subclass of :py:class:`.red_base.BaseDriver`.
|
||||
"""
|
||||
def __init__(self, cog_name, **kwargs):
|
||||
super().__init__(cog_name)
|
||||
def __init__(self, cog_name, identifier, **kwargs):
|
||||
super().__init__(cog_name, identifier)
|
||||
|
||||
if _conn is None:
|
||||
_initialize(**kwargs)
|
||||
@@ -105,10 +105,15 @@ class Mongo(BaseDriver):
|
||||
dot_identifiers = '.'.join(identifiers)
|
||||
mongo_collection = self.get_collection()
|
||||
|
||||
await mongo_collection.update_one(
|
||||
{'_id': self.unique_cog_identifier},
|
||||
update={"$unset": {dot_identifiers: 1}}
|
||||
)
|
||||
if len(identifiers) > 0:
|
||||
await mongo_collection.update_one(
|
||||
{'_id': self.unique_cog_identifier},
|
||||
update={"$unset": {dot_identifiers: 1}}
|
||||
)
|
||||
else:
|
||||
await mongo_collection.delete_one(
|
||||
{'_id': self.unique_cog_identifier}
|
||||
)
|
||||
|
||||
|
||||
def get_config_details():
|
||||
|
||||
Reference in New Issue
Block a user