@@ -366,7 +366,6 @@ def index(request, task_id=None, resubmit_hash=None):
366366 opt_apikey = opts .get ("apikey" , False )
367367
368368 status = "ok"
369- task_ids_tmp = []
370369 existent_tasks = {}
371370 details = {
372371 "errors" : [],
@@ -508,17 +507,13 @@ def index(request, task_id=None, resubmit_hash=None):
508507
509508 details ["path" ] = path
510509 details ["content" ] = content
511- result = download_file (** details )
512- if len (result ) == 2 :
513- status , task_ids_tmp = result
514- elif len (result ) == 3 :
515- status , task_ids_tmp , demux_error_msg = result
516- if demux_error_msg :
517- details ["errors" ].extend (demux_error_msg )
510+ status , tasks_details = download_file (** details )
518511 if status == "error" :
519- details ["errors" ].append ({os .path .basename (filename ): task_ids_tmp })
512+ details ["errors" ].append ({os .path .basename (filename ): tasks_details })
520513 else :
521- details ["task_ids" ] = task_ids_tmp
514+ details ["task_ids" ] = tasks_details .get ("task_ids" )
515+ if tasks_details .get ("errors" ):
516+ details ["errors" ].extend (tasks_details ["errors" ])
522517 if web_conf .web_reporting .get ("enabled" , False ) and web_conf .general .get ("existent_tasks" , False ):
523518 records = perform_search ("target_sha256" , hash , search_limit = 5 )
524519 if records :
@@ -543,23 +538,19 @@ def index(request, task_id=None, resubmit_hash=None):
543538
544539 details ["path" ] = path
545540 details ["content" ] = content
546- result = download_file (** details )
547- if len (result ) == 2 :
548- status , task_ids_tmp = result
549- elif len (result ) == 3 :
550- status , task_ids_tmp , demux_error_msg = result
551- if demux_error_msg :
552- details ["errors" ].extend (demux_error_msg )
541+ status , tasks_details = download_file (** details )
553542 if status == "error" :
554- details ["errors" ].append ({os .path .basename (path ): task_ids_tmp })
543+ details ["errors" ].append ({os .path .basename (path ): tasks_details })
555544 else :
545+ details ["task_ids" ] = tasks_details .get ("task_ids" )
546+ if tasks_details .get ("errors" ):
547+ details ["errors" ].extend (tasks_details ["errors" ])
556548 if web_conf .general .get ("existent_tasks" , False ):
557549 records = perform_search ("target_sha256" , sha256 , search_limit = 5 )
558550 if records :
559551 for record in records :
560552 if record .get ("target" ).get ("file" , {}).get ("sha256" ):
561553 existent_tasks .setdefault (record ["target" ]["file" ]["sha256" ], []).append (record )
562- details ["task_ids" ] = task_ids_tmp
563554
564555 elif task_category == "static" :
565556 for content , path , sha256 in list_of_tasks :
@@ -631,18 +622,13 @@ def index(request, task_id=None, resubmit_hash=None):
631622 details ["content" ] = content
632623 details ["service" ] = "DLnExec"
633624 details ["source_url" ] = samples
634- result = download_file (** details )
635- if len (result ) == 2 :
636- status , task_ids_tmp = result
637- elif len (result ) == 3 :
638- status , task_ids_tmp , demux_error_msg = result
639- if demux_error_msg :
640- details ["errors" ].extend (demux_error_msg )
641-
625+ status , tasks_details = download_file (** details )
642626 if status == "error" :
643- details ["errors" ].append ({os .path .basename (path ): task_ids_tmp })
627+ details ["errors" ].append ({os .path .basename (path ): tasks_details })
644628 else :
645- details ["task_ids" ] = task_ids_tmp
629+ details ["task_ids" ] = tasks_details .get ("task_ids" )
630+ if tasks_details .get ("errors" ):
631+ details ["errors" ].extend (tasks_details ["errors" ])
646632
647633 elif task_category == "vtdl" :
648634 if not settings .VTDL_KEY :
0 commit comments