From cb86fb1e9a4c82b9fc8b1ea3d65e66c0165ac7cf Mon Sep 17 00:00:00 2001 From: Yash Oswal Date: Tue, 18 Oct 2022 11:15:53 +0530 Subject: [PATCH] Fix issue to update over current database (#44) --- helpers/utils.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/helpers/utils.py b/helpers/utils.py index 41fb9888..530444e1 100644 --- a/helpers/utils.py +++ b/helpers/utils.py @@ -67,26 +67,29 @@ def __init__(self, uid: int, name:str): # def __init__(self,uid:int,name:str,merge_mode:int=1,edit_metadata=False) -> None: def get(self): - cur = getUserMergeSettings(self.user_id) - if cur is not None: - self.name = cur["name"] - self.merge_mode = cur["user_settings"]["merge_mode"] - self.edit_metadata = cur["user_settings"]["edit_metadata"] - self.allowed = cur["isAllowed"] - self.thumbnail = cur["thumbnail"] - self.banned = cur["isBanned"] - return { - "uid": self.user_id, - "name": self.name, - "user_settings": { - "merge_mode": self.merge_mode, - "edit_metadata": self.edit_metadata, - }, - "isAllowed": self.allowed, - "isBanned": self.banned, - "thumbnail": self.thumbnail, - } - else: return self.set() + try: + cur = getUserMergeSettings(self.user_id) + if cur is not None: + self.name = cur["name"] + self.merge_mode = cur["user_settings"]["merge_mode"] + self.edit_metadata = cur["user_settings"]["edit_metadata"] + self.allowed = cur["isAllowed"] + self.thumbnail = cur["thumbnail"] + self.banned = cur["isBanned"] + return { + "uid": self.user_id, + "name": self.name, + "user_settings": { + "merge_mode": self.merge_mode, + "edit_metadata": self.edit_metadata, + }, + "isAllowed": self.allowed, + "isBanned": self.banned, + "thumbnail": self.thumbnail, + } + else: return self.set() + except KeyError: + return self.set() def set(self): setUserMergeSettings(