29
29
from app .services .output_manager .error_handler import ECustomizedError
30
30
from app .services .output_manager .error_handler import SrvErrorHandler
31
31
from app .services .user_authentication .decorator import require_valid_token
32
+ from app .utils .aggregated import ItemStatus
32
33
from app .utils .aggregated import get_file_info_by_geid
33
34
34
35
from .exception import INVALID_CHUNK_ETAG
@@ -354,10 +355,11 @@ def on_complete(result):
354
355
355
356
# for resumable check ONLY if user resume the upload at 100%
356
357
# just check if there is any active job, if not, set the event
357
- while not chunk_upload_done .wait (timeout = 60 ):
358
+ while not chunk_upload_done .wait (timeout = 5 ):
358
359
if self .active_jobs == 0 :
359
360
chunk_upload_done .set ()
360
- logger .warning ('Waiting for all the chunks to be uploaded, remaining jobs: %s' , file_object .progress )
361
+ else :
362
+ logger .warning ('Waiting for all the chunks to be uploaded, remaining jobs: %s' , self .active_jobs )
361
363
362
364
f .close ()
363
365
@@ -447,7 +449,7 @@ def on_succeed(self, file_object: FileObject) -> None:
447
449
result = response .json ().get ('result' )
448
450
return result
449
451
450
- def check_status (self , file_object : FileObject ) -> bool :
452
+ def check_status (self , file_objects : list [ FileObject ] ) -> list [ FileObject ] :
451
453
"""
452
454
Summary:
453
455
The function is to check the status of upload process.
@@ -458,14 +460,15 @@ def check_status(self, file_object: FileObject) -> bool:
458
460
- bool: if job success or not
459
461
"""
460
462
461
- # with pre-register upload, we can check if the file entity is already exist
462
- # if exist, we can continue with manifest process
463
- file_entity = get_file_info_by_geid ([file_object .item_id ])[0 ].get ('result' , {})
464
- mhandler .SrvOutPutHandler .finalize_upload ()
465
- if file_entity .get ('status' ) == 'ACTIVE' :
466
- return True
467
- else :
468
- return False
463
+ file_ids = [file_object .item_id for file_object in file_objects ]
464
+ results = get_file_info_by_geid (file_ids )
465
+ unfinished_files = []
466
+ for r in results :
467
+ status = r .get ('status' )
468
+ if status != ItemStatus .ACTIVE :
469
+ unfinished_files .append (r .get ('result' ))
470
+
471
+ return unfinished_files
469
472
470
473
def set_finish_upload (self ):
471
474
self .finish_upload = True
0 commit comments