@@ -339,25 +339,24 @@ def upload_one_by_one(
339339):
340340 """Upload files one by one with uploading the slices concurrently"""
341341
342- with _progress :
343- for from_to in from_to_list :
344- task_id = None
345- if show_progress :
346- task_id = _progress .add_task ("upload" , start = False , title = from_to .from_ )
347- upload_file_concurrently (
348- api ,
349- from_to ,
350- ondup ,
351- max_workers = max_workers ,
352- encrypt_password = encrypt_password ,
353- encrypt_type = encrypt_type ,
354- slice_size = slice_size ,
355- ignore_existing = ignore_existing ,
356- task_id = task_id ,
357- user_id = user_id ,
358- user_name = user_name ,
359- check_md5 = check_md5 ,
360- )
342+ for from_to in from_to_list :
343+ task_id = None
344+ if show_progress :
345+ task_id = _progress .add_task ("upload" , start = False , title = from_to .from_ )
346+ upload_file_concurrently (
347+ api ,
348+ from_to ,
349+ ondup ,
350+ max_workers = max_workers ,
351+ encrypt_password = encrypt_password ,
352+ encrypt_type = encrypt_type ,
353+ slice_size = slice_size ,
354+ ignore_existing = ignore_existing ,
355+ task_id = task_id ,
356+ user_id = user_id ,
357+ user_name = user_name ,
358+ check_md5 = check_md5 ,
359+ )
361360
362361 logger .debug ("======== Uploading end ========" )
363362
@@ -570,44 +569,39 @@ def upload_many(
570569
571570 excepts = {}
572571 semaphore = Semaphore (max_workers )
573- with _progress :
574- with ThreadPoolExecutor (max_workers = max_workers ) as executor :
575- futs = {}
576- for idx , from_to in enumerate (from_to_list ):
577- semaphore .acquire ()
578- task_id = None
579- if show_progress :
580- task_id = _progress .add_task (
581- "upload" , start = False , title = from_to .from_
582- )
583-
584- logger .debug (
585- "`upload_many`: Upload: index: %s, task_id: %s" , idx , task_id
586- )
572+ with ThreadPoolExecutor (max_workers = max_workers ) as executor :
573+ futs = {}
574+ for idx , from_to in enumerate (from_to_list ):
575+ semaphore .acquire ()
576+ task_id = None
577+ if show_progress :
578+ task_id = _progress .add_task ("upload" , start = False , title = from_to .from_ )
587579
588- fut = executor .submit (
589- sure_release ,
590- semaphore ,
591- upload_file ,
592- api ,
593- from_to ,
594- ondup ,
595- encrypt_password = encrypt_password ,
596- encrypt_type = encrypt_type ,
597- slice_size = slice_size ,
598- ignore_existing = ignore_existing ,
599- task_id = task_id ,
600- user_id = user_id ,
601- user_name = user_name ,
602- check_md5 = check_md5 ,
603- )
604- futs [fut ] = from_to
580+ logger .debug ("`upload_many`: Upload: index: %s, task_id: %s" , idx , task_id )
581+
582+ fut = executor .submit (
583+ sure_release ,
584+ semaphore ,
585+ upload_file ,
586+ api ,
587+ from_to ,
588+ ondup ,
589+ encrypt_password = encrypt_password ,
590+ encrypt_type = encrypt_type ,
591+ slice_size = slice_size ,
592+ ignore_existing = ignore_existing ,
593+ task_id = task_id ,
594+ user_id = user_id ,
595+ user_name = user_name ,
596+ check_md5 = check_md5 ,
597+ )
598+ futs [fut ] = from_to
605599
606- for fut in as_completed (futs ):
607- e = fut .exception ()
608- if e is not None :
609- from_to = futs [fut ]
610- excepts [from_to ] = e
600+ for fut in as_completed (futs ):
601+ e = fut .exception ()
602+ if e is not None :
603+ from_to = futs [fut ]
604+ excepts [from_to ] = e
611605
612606 logger .debug ("======== Uploading end ========" )
613607
0 commit comments