Commit 25da169b authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix save_gdrive_file()

parent 384cf457
...@@ -33,14 +33,17 @@ else: ...@@ -33,14 +33,17 @@ else:
with open('gdrive_token.pickle', 'wb') as f: with open('gdrive_token.pickle', 'wb') as f:
pickle.dump(creds, f) pickle.dump(creds, f)
drive_service = None gdrive_service = None
def save_gdrive_file(file_id, fobj): def save_gdrive_file(file_id, fobj, check_health=False):
global gdrive_service, creds global gdrive_service, creds
if gdrive_service is None: if gdrive_service is None:
drive_service = build('drive', 'v3', credentials=creds) gdrive_service = build('drive', 'v3', credentials=creds)
request = drive_service.files().get_media(fileId=file_id) request = gdrive_service.files().get_media(fileId=file_id)
downloader = MediaIoBaseDownload(fobj, request) downloader = MediaIoBaseDownload(fobj, request,
chunksize=104857600 if not check_health else 1)
done = False done = False
while not done: while not done:
status, done = downloader.next_chunk() status, done = downloader.next_chunk()
if check_health:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment