async downloadSingleArtifactToStream()

in gh-actions-artifact-client/src/download-http-client.js [48:73]


  async downloadSingleArtifactToStream(downloadItems, outputStream) {
    let currentFile = 0
    console.error(
      `Total number of files that will be downloaded: ${downloadItems.length}`
    )
    this.statusReporter.setTotalNumberOfFilesToProcess(downloadItems.length)
    this.statusReporter.start()
    try {
      while (currentFile < downloadItems.length) {
        const currentFileToDownload = downloadItems[currentFile]
        currentFile += 1
        await this.downloadIndividualFileToStream(
          0,
          currentFileToDownload.sourceLocation,
          outputStream
        )
        this.statusReporter.incrementProcessedCount()
      }
    } catch (error) {
      throw new Error(`Unable to download the artifact: ${error}`)
    } finally {
      this.statusReporter.stop()
      // safety dispose all connections
      this.downloadHttpManager.disposeAndReplaceAllClients()
    }
  }