@@ -2231,24 +2231,27 @@ def fail(message=job.info, exception=None):
22312231 dataset .full_delete ()
22322232 collected_bytes = 0
22332233
2234- # Calculate dataset hash
2235- for dataset_assoc in output_dataset_associations :
2236- dataset = dataset_assoc .dataset .dataset
2237- if not dataset .purged and dataset .state == Dataset .states .OK and not dataset .hashes :
2238- if self .app .config .calculate_dataset_hash == "always" or (
2239- self .app .config .calculate_dataset_hash == "upload" and job .tool_id in ("upload1" , "__DATA_FETCH__" )
2240- ):
2241- # Calculate dataset hash via a celery task
2242- if self .app .config .enable_celery_tasks :
2243- from galaxy .celery .tasks import compute_dataset_hash
2244-
2245- extra_files_path = dataset .extra_files_path if dataset .extra_files_path_exists () else None
2246- request = ComputeDatasetHashTaskRequest (
2247- dataset_id = dataset .id ,
2248- extra_files_path = extra_files_path ,
2249- hash_function = self .app .config .hash_function ,
2250- )
2251- compute_dataset_hash .delay (request = request )
2234+ # Calculate dataset hash - only if the job completed successfully,
2235+ # otherwise dataset files may be missing/invalid (e.g. failed fetch from 404 URL).
2236+ if final_job_state == job .states .OK :
2237+ for dataset_assoc in output_dataset_associations :
2238+ dataset = dataset_assoc .dataset .dataset
2239+ if not dataset .purged and dataset .state == Dataset .states .OK and not dataset .hashes :
2240+ if self .app .config .calculate_dataset_hash == "always" or (
2241+ self .app .config .calculate_dataset_hash == "upload"
2242+ and job .tool_id in ("upload1" , "__DATA_FETCH__" )
2243+ ):
2244+ # Calculate dataset hash via a celery task
2245+ if self .app .config .enable_celery_tasks :
2246+ from galaxy .celery .tasks import compute_dataset_hash
2247+
2248+ extra_files_path = dataset .extra_files_path if dataset .extra_files_path_exists () else None
2249+ request = ComputeDatasetHashTaskRequest (
2250+ dataset_id = dataset .id ,
2251+ extra_files_path = extra_files_path ,
2252+ hash_function = self .app .config .hash_function ,
2253+ )
2254+ compute_dataset_hash .delay (request = request )
22522255
22532256 user = job .user
22542257 if user and collected_bytes > 0 and quota_source_info is not None and quota_source_info .use :
0 commit comments