mirror of
				https://gitea.com/actions/download-artifact.git
				synced 2025-10-31 00:58:16 +07:00 
			
		
		
		
	Refactor loop, break for testing
This commit is contained in:
		
							parent
							
								
									a8a786b097
								
							
						
					
					
						commit
						503e7a18ae
					
				
							
								
								
									
										20
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -118769,21 +118769,27 @@ function run() { | |||||||
|                 core.info(`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size})`); |                 core.info(`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size})`); | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|         const downloadPromises = artifacts.map(artifact => artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple |         const downloadPromises = artifacts.map(artifact => ({ | ||||||
|  |             name: artifact.name, | ||||||
|  |             promise: artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple | ||||||
|                     ? resolvedPath |                     ? resolvedPath | ||||||
|                 : path.join(resolvedPath, artifact.name), expectedHash: artifact.digest }))); |                     : path.join(resolvedPath, artifact.name), expectedHash: artifact.digest })) | ||||||
|  |         })); | ||||||
|         const chunkedPromises = (0, exports.chunk)(downloadPromises, PARALLEL_DOWNLOADS); |         const chunkedPromises = (0, exports.chunk)(downloadPromises, PARALLEL_DOWNLOADS); | ||||||
|         for (const chunk of chunkedPromises) { |         for (const chunk of chunkedPromises) { | ||||||
|             const result = yield Promise.all(chunk); |             const chunkPromises = chunk.map(item => item.promise); | ||||||
|             for (const outcome of result) { |             const results = yield Promise.all(chunkPromises); | ||||||
|                 if (outcome.digestMismatch) { |             for (let i = 0; i < results.length; i++) { | ||||||
|                     core.warning(`Artifact digest validation failed. Please verify the integrity of the artifact.`); |                 const outcome = results[i]; | ||||||
|                 } |                 const artifactName = chunk[i].name; | ||||||
|  |                 if (!outcome.digestMismatch) { | ||||||
|  |                     core.warning(`Artifact '${artifactName}' digest validation failed. Please verify the integrity of the artifact.`); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             core.info(`Total of ${artifacts.length} artifact(s) downloaded`); |             core.info(`Total of ${artifacts.length} artifact(s) downloaded`); | ||||||
|             core.setOutput(constants_1.Outputs.DownloadPath, resolvedPath); |             core.setOutput(constants_1.Outputs.DownloadPath, resolvedPath); | ||||||
|             core.info('Download artifact has finished successfully'); |             core.info('Download artifact has finished successfully'); | ||||||
|  |         } | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| run().catch(err => core.setFailed(`Unable to download artifact(s): ${err.message}`)); | run().catch(err => core.setFailed(`Unable to download artifact(s): ${err.message}`)); | ||||||
|  | |||||||
| @ -111,8 +111,9 @@ async function run(): Promise<void> { | |||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   const downloadPromises = artifacts.map(artifact => |   const downloadPromises = artifacts.map(artifact => ({ | ||||||
|     artifactClient.downloadArtifact(artifact.id, { |     name: artifact.name, | ||||||
|  |     promise: artifactClient.downloadArtifact(artifact.id, { | ||||||
|       ...options, |       ...options, | ||||||
|       path: |       path: | ||||||
|         isSingleArtifactDownload || inputs.mergeMultiple |         isSingleArtifactDownload || inputs.mergeMultiple | ||||||
| @ -120,24 +121,29 @@ async function run(): Promise<void> { | |||||||
|           : path.join(resolvedPath, artifact.name), |           : path.join(resolvedPath, artifact.name), | ||||||
|       expectedHash: artifact.digest |       expectedHash: artifact.digest | ||||||
|     }) |     }) | ||||||
|   ) |   })) | ||||||
| 
 | 
 | ||||||
|   const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS) |   const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS) | ||||||
|   for (const chunk of chunkedPromises) { |   for (const chunk of chunkedPromises) { | ||||||
|     const result = await Promise.all(chunk) |     const chunkPromises = chunk.map(item => item.promise) | ||||||
|     for (const outcome of result) { |     const results = await Promise.all(chunkPromises) | ||||||
|       if (outcome.digestMismatch) { | 
 | ||||||
|  |     for (let i = 0; i < results.length; i++) { | ||||||
|  |       const outcome = results[i] | ||||||
|  |       const artifactName = chunk[i].name | ||||||
|  | 
 | ||||||
|  |       if (!outcome.digestMismatch) { | ||||||
|         core.warning( |         core.warning( | ||||||
|           `Artifact digest validation failed. Please verify the integrity of the artifact.` |           `Artifact '${artifactName}' digest validation failed. Please verify the integrity of the artifact.` | ||||||
|         ) |         ) | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|     core.info(`Total of ${artifacts.length} artifact(s) downloaded`) |     core.info(`Total of ${artifacts.length} artifact(s) downloaded`) | ||||||
|     core.setOutput(Outputs.DownloadPath, resolvedPath) |     core.setOutput(Outputs.DownloadPath, resolvedPath) | ||||||
|     core.info('Download artifact has finished successfully') |     core.info('Download artifact has finished successfully') | ||||||
|   } |   } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| run().catch(err => | run().catch(err => | ||||||
|   core.setFailed(`Unable to download artifact(s): ${err.message}`) |   core.setFailed(`Unable to download artifact(s): ${err.message}`) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user