@@ -78,8 +78,7 @@ function pipeline_lib.merge_metadata(existing_metadata, new_metadata)
7878 return merged
7979end
8080
81- -- Invoke upload completion token callback (fire-and-forget)
82- function pipeline_lib .invoke_upload_token (upload , success , error_msg )
81+ function pipeline_lib .invoke_upload_token (upload , status , error_msg )
8382 if not upload or not upload .metadata or not upload .metadata .__upload_token then
8483 return
8584 end
@@ -90,7 +89,11 @@ function pipeline_lib.invoke_upload_token(upload, success, error_msg)
9089 return
9190 end
9291
93- local func_id = tostring (success and payload .function_id or payload .on_error_id )
92+ if status == STATUS .UPLOADED and not payload .announce_uploaded then
93+ return
94+ end
95+
96+ local func_id = tostring (status == STATUS .ERROR and payload .on_error_id or payload .function_id )
9497 if not func_id or func_id == " nil" then
9598 return
9699 end
@@ -118,7 +121,7 @@ function pipeline_lib.invoke_upload_token(upload, success, error_msg)
118121
119122 local _ , call_err = executor :call (tostring (func_id ), {
120123 upload_id = upload .uuid ,
121- status = success and " completed " or " error " ,
124+ status = status ,
122125 error = error_msg ,
123126 mime_type = upload .mime_type ,
124127 size = upload .size ,
@@ -165,7 +168,7 @@ function pipeline_lib.process_upload(upload)
165168 -- Notify about error status
166169 pipeline_lib .notify_status_change (upload , STATUS .ERROR , nil , error_msg )
167170
168- pipeline_lib .invoke_upload_token (upload , false , error_msg )
171+ pipeline_lib .invoke_upload_token (upload , STATUS . ERROR , error_msg )
169172
170173 return false , error_msg
171174 end
@@ -190,7 +193,7 @@ function pipeline_lib.process_upload(upload)
190193 -- Notify about error status
191194 pipeline_lib .notify_status_change (upload , STATUS .ERROR , nil , error_msg )
192195
193- pipeline_lib .invoke_upload_token (upload , false , error_msg )
196+ pipeline_lib .invoke_upload_token (upload , STATUS . ERROR , error_msg )
194197
195198 return false , error_msg
196199 end
@@ -245,7 +248,7 @@ function pipeline_lib.process_upload(upload)
245248 -- Notify about error status with stage info
246249 pipeline_lib .notify_status_change (upload , STATUS .ERROR , stage_title , error_msg )
247250
248- pipeline_lib .invoke_upload_token (upload , false , error_msg )
251+ pipeline_lib .invoke_upload_token (upload , STATUS . ERROR , error_msg )
249252
250253 return false , error_msg
251254 end
@@ -279,12 +282,12 @@ function pipeline_lib.process_upload(upload)
279282 -- Notify about completion status
280283 pipeline_lib .notify_status_change (upload , STATUS .COMPLETED )
281284
282- pipeline_lib .invoke_upload_token (upload , true , nil )
285+ pipeline_lib .invoke_upload_token (upload , STATUS . COMPLETED )
283286
284287 return true
285288end
286289
287290-- Export constants
288291pipeline_lib .STATUS = STATUS
289292
290- return pipeline_lib
293+ return pipeline_lib
0 commit comments