Use Service Accounts for Cloning if availble.
- increase default timeout for network socket interface Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
6181b022ac
commit
be9c64a9aa
|
|
@ -6,6 +6,9 @@ import time
|
|||
import aria2p
|
||||
import telegram.ext as tg
|
||||
from dotenv import load_dotenv
|
||||
import socket
|
||||
|
||||
socket.setdefaulttimeout(600)
|
||||
|
||||
botStartTime = time.time()
|
||||
if os.path.exists('log.txt'):
|
||||
|
|
|
|||
|
|
@ -228,7 +228,20 @@ class GoogleDriveHelper:
|
|||
body = {
|
||||
'parents': [dest_id]
|
||||
}
|
||||
return self.__service.files().copy(supportsAllDrives=True, fileId=file_id, body=body).execute()
|
||||
|
||||
try:
|
||||
res = self.__service.files().copy(supportsAllDrives=True,fileId=file_id,body=body).execute()
|
||||
return res
|
||||
except HttpError as err:
|
||||
if err.resp.get('content-type', '').startswith('application/json'):
|
||||
reason = json.loads(err.content).get('error').get('errors')[0].get('reason')
|
||||
if reason == 'userRateLimitExceeded' or reason == 'dailyLimitExceeded':
|
||||
if USE_SERVICE_ACCOUNTS:
|
||||
self.switchServiceAccount()
|
||||
LOGGER.info(f"Got: {reason}, Trying Again.")
|
||||
self.copyFile(file_id,dest_id)
|
||||
else:
|
||||
raise err
|
||||
|
||||
def clone(self, link):
|
||||
self.transferred_size = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue