@@ -364,21 +364,30 @@ def cp_file(self, lpath, rpath, **kwargs):
364
364
buffer = io .BytesIO (stream .read ())
365
365
self .upload_fobj (buffer , rpath )
366
366
367
- def get_file (self , lpath , rpath , callback = None , ** kwargs ):
367
+ def get_file (self , lpath , rpath , callback = None , block_size = None , ** kwargs ):
368
368
item_id = self ._get_item_id (lpath )
369
- return self .gdrive_get_file (item_id , rpath , callback )
369
+ return self .gdrive_get_file (
370
+ item_id , rpath , callback = callback , block_size = block_size
371
+ )
370
372
371
373
@_gdrive_retry
372
- def gdrive_get_file (self , item_id , rpath , callback ):
374
+ def gdrive_get_file (self , item_id , rpath , callback = None , block_size = None ):
373
375
param = {"id" : item_id }
374
376
# it does not create a file on the remote
375
377
gdrive_file = self .client .CreateFile (param )
376
378
377
379
extra_args = {}
380
+ if block_size :
381
+ extra_args ["chunksize" ] = block_size
382
+
378
383
if callback :
384
+
385
+ def cb (value , _ ):
386
+ callback .absolute_update (value )
387
+
379
388
gdrive_file .FetchMetadata (fields = "fileSize" )
380
389
callback .set_size (int (gdrive_file .get ("fileSize" )))
381
- extra_args ["callback" ] = callback . update
390
+ extra_args ["callback" ] = cb
382
391
383
392
gdrive_file .GetContentFile (rpath , ** extra_args )
384
393
0 commit comments