mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 11:25:31 +00:00
Use promisify of stream.pipeline for downloading
This commit is contained in:
parent
48b62c1c52
commit
1ed0c23029
3 changed files with 29 additions and 18 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue