mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
[Config] Migrate UUID for JSON backend (#2604)
* Migrate UUID for JSON backend * Interesting... * black * Simplify UUID creation
This commit is contained in:
@@ -7,7 +7,7 @@ import weakref
|
||||
import discord
|
||||
|
||||
from .data_manager import cog_data_path, core_data_path
|
||||
from .drivers import get_driver, IdentifierData
|
||||
from .drivers import get_driver, IdentifierData, BackendType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .drivers.red_base import BaseDriver
|
||||
@@ -562,6 +562,10 @@ class Config:
|
||||
def defaults(self):
|
||||
return deepcopy(self._defaults)
|
||||
|
||||
@staticmethod
|
||||
def _create_uuid(identifier: int):
|
||||
return str(identifier)
|
||||
|
||||
@classmethod
|
||||
def get_conf(cls, cog_instance, identifier: int, force_registration=False, cog_name=None):
|
||||
"""Get a Config instance for your cog.
|
||||
@@ -602,7 +606,8 @@ class Config:
|
||||
cog_path_override = cog_data_path(cog_instance=cog_instance)
|
||||
|
||||
cog_name = cog_path_override.stem
|
||||
uuid = str(hash(identifier))
|
||||
# uuid = str(hash(identifier))
|
||||
uuid = cls._create_uuid(identifier)
|
||||
|
||||
# We have to import this here otherwise we have a circular dependency
|
||||
from .data_manager import basic_config
|
||||
@@ -613,6 +618,9 @@ class Config:
|
||||
driver = get_driver(
|
||||
driver_name, cog_name, uuid, data_path_override=cog_path_override, **driver_details
|
||||
)
|
||||
if driver_name == BackendType.JSON.value:
|
||||
driver.migrate_identifier(identifier)
|
||||
|
||||
conf = cls(
|
||||
cog_name=cog_name,
|
||||
unique_identifier=uuid,
|
||||
|
||||
Reference in New Issue
Block a user