Skip to content

Commit

Permalink
Fix random SA switching issue
Browse files Browse the repository at this point in the history
  • Loading branch information
l3v11 authored Sep 1, 2022
1 parent 783f6d6 commit 7ed265c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bot/helper/drive_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand All @@ -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)
Expand Down

0 comments on commit 7ed265c

Please sign in to comment.