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 aria2p
|
||||||
import telegram.ext as tg
|
import telegram.ext as tg
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
import socket
|
||||||
|
|
||||||
|
socket.setdefaulttimeout(600)
|
||||||
|
|
||||||
botStartTime = time.time()
|
botStartTime = time.time()
|
||||||
if os.path.exists('log.txt'):
|
if os.path.exists('log.txt'):
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,20 @@ class GoogleDriveHelper:
|
||||||
body = {
|
body = {
|
||||||
'parents': [dest_id]
|
'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):
|
def clone(self, link):
|
||||||
self.transferred_size = 0
|
self.transferred_size = 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue