3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-22 11:25:31 +00:00

Merge pull request #284 from actions/promisify-pipeline

Better error handling during download
This commit is contained in:
David Hadka 2020-04-29 13:50:12 -05:00 committed by GitHub
commit 9f07ee13de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 18 deletions

View file

@ -8,6 +8,8 @@ import {
} from "@actions/http-client/interfaces";
import * as crypto from "crypto";
import * as fs from "fs";
import * as stream from "stream";
import * as util from "util";
import { Inputs, SocketTimeout } from "./constants";
import {
@ -128,13 +130,10 @@ export async function getCacheEntry(
async function pipeResponseToStream(
response: IHttpClientResponse,
stream: NodeJS.WritableStream
output: NodeJS.WritableStream
): Promise<void> {
return new Promise(resolve => {
response.message.pipe(stream).on("close", () => {
resolve();
});
});
const pipeline = util.promisify(stream.pipeline);
await pipeline(response.message, output);
}
export async function downloadCache(