From 7ed265ce7bdf758f1782ddfeb2e2b6328688a813 Mon Sep 17 00:00:00 2001 From: Levi <57452819+l3v11@users.noreply.github.com> Date: Thu, 1 Sep 2022 18:13:55 +0600 Subject: [PATCH] Fix random SA switching issue --- bot/helper/drive_utils/gdriveTools.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/helper/drive_utils/gdriveTools.py b/bot/helper/drive_utils/gdriveTools.py index e8b8bc4a..3fafec56 100644 --- a/bot/helper/drive_utils/gdriveTools.py +++ b/bot/helper/drive_utils/gdriveTools.py @@ -43,7 +43,6 @@ def __init__(self, name=None, path=None, size=0, listener=None): self.__path = path self.__size = size self.__listener = listener - self.__service = self.__authorize() self.__total_bytes = 0 self.__total_folders = 0 self.__total_files = 0 @@ -66,6 +65,7 @@ def __init__(self, name=None, path=None, size=0, listener=None): self.response = {} self.telegraph_path = [] self.telegraph_content = [] + self.__service = self.__authorize() def speed(self): """ @@ -90,7 +90,8 @@ def cspeed(self): def __authorize(self): creds = None if USE_SERVICE_ACCOUNTS: - self.__service_account_index = randrange(SERVICE_ACCOUNTS_NUMBER) + if self.__sa_count == 0: + self.__service_account_index = randrange(SERVICE_ACCOUNTS_NUMBER) LOGGER.info(f"Authorizing with {self.__service_account_index}.json file") creds = service_account.Credentials.from_service_account_file( f'accounts/{self.__service_account_index}.json', scopes=self.__OAUTH_SCOPE)