mirror of
https://github.com/actions/cache.git
synced 2024-12-27 09:45:24 +01:00
Use promisify of stream.pipeline for downloading
This commit is contained in:
parent
2a973a0f4e
commit
ec7f7ebd08
3 changed files with 33 additions and 28 deletions
23
dist/restore/index.js
vendored
23
dist/restore/index.js
vendored
|
@ -1255,6 +1255,9 @@ const core = __importStar(__webpack_require__(470));
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const auth_1 = __webpack_require__(226);
|
const auth_1 = __webpack_require__(226);
|
||||||
const http_client_1 = __webpack_require__(539);
|
const http_client_1 = __webpack_require__(539);
|
||||||
|
const stream = __importStar(__webpack_require__(794));
|
||||||
|
const util = __importStar(__webpack_require__(669));
|
||||||
|
const constants_1 = __webpack_require__(694);
|
||||||
const utils = __importStar(__webpack_require__(443));
|
const utils = __importStar(__webpack_require__(443));
|
||||||
const constants_1 = __webpack_require__(694);
|
const constants_1 = __webpack_require__(694);
|
||||||
function isSuccessStatusCode(statusCode) {
|
function isSuccessStatusCode(statusCode) {
|
||||||
|
@ -1326,13 +1329,10 @@ function getCacheEntry(keys) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getCacheEntry = getCacheEntry;
|
exports.getCacheEntry = getCacheEntry;
|
||||||
function pipeResponseToStream(response, stream) {
|
function pipeResponseToStream(response, output) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return new Promise(resolve => {
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
response.message.pipe(stream).on("close", () => {
|
yield pipeline(response.message, output);
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function downloadCache(archiveLocation, archivePath) {
|
function downloadCache(archiveLocation, archivePath) {
|
||||||
|
@ -1665,10 +1665,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
const glob = __importStar(__webpack_require__(281));
|
|
||||||
>>>>>>> 9bb13c7... Fix lint issue, build .js files
|
|
||||||
const io = __importStar(__webpack_require__(1));
|
const io = __importStar(__webpack_require__(1));
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
@ -2894,6 +2890,13 @@ run();
|
||||||
exports.default = run;
|
exports.default = run;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 794:
|
||||||
|
/***/ (function(module) {
|
||||||
|
|
||||||
|
module.exports = require("stream");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 826:
|
/***/ 826:
|
||||||
|
|
23
dist/save/index.js
vendored
23
dist/save/index.js
vendored
|
@ -1255,6 +1255,9 @@ const core = __importStar(__webpack_require__(470));
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const auth_1 = __webpack_require__(226);
|
const auth_1 = __webpack_require__(226);
|
||||||
const http_client_1 = __webpack_require__(539);
|
const http_client_1 = __webpack_require__(539);
|
||||||
|
const stream = __importStar(__webpack_require__(794));
|
||||||
|
const util = __importStar(__webpack_require__(669));
|
||||||
|
const constants_1 = __webpack_require__(694);
|
||||||
const utils = __importStar(__webpack_require__(443));
|
const utils = __importStar(__webpack_require__(443));
|
||||||
function isSuccessStatusCode(statusCode) {
|
function isSuccessStatusCode(statusCode) {
|
||||||
if (!statusCode) {
|
if (!statusCode) {
|
||||||
|
@ -1325,13 +1328,10 @@ function getCacheEntry(keys) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getCacheEntry = getCacheEntry;
|
exports.getCacheEntry = getCacheEntry;
|
||||||
function pipeResponseToStream(response, stream) {
|
function pipeResponseToStream(response, output) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return new Promise(resolve => {
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
response.message.pipe(stream).on("close", () => {
|
yield pipeline(response.message, output);
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function downloadCache(archiveLocation, archivePath) {
|
function downloadCache(archiveLocation, archivePath) {
|
||||||
|
@ -1664,10 +1664,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
const glob = __importStar(__webpack_require__(281));
|
|
||||||
>>>>>>> 9bb13c7... Fix lint issue, build .js files
|
|
||||||
const io = __importStar(__webpack_require__(1));
|
const io = __importStar(__webpack_require__(1));
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
@ -2876,6 +2872,13 @@ module.exports = require("fs");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 794:
|
||||||
|
/***/ (function(module) {
|
||||||
|
|
||||||
|
module.exports = require("stream");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 826:
|
/***/ 826:
|
||||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import * as fs from "fs";
|
|
||||||
import { BearerCredentialHandler } from "@actions/http-client/auth";
|
|
||||||
import { HttpClient, HttpCodes } from "@actions/http-client";
|
import { HttpClient, HttpCodes } from "@actions/http-client";
|
||||||
|
import { BearerCredentialHandler } from "@actions/http-client/auth";
|
||||||
import {
|
import {
|
||||||
IHttpClientResponse,
|
IHttpClientResponse,
|
||||||
IRequestOptions,
|
IRequestOptions,
|
||||||
ITypedResponse
|
ITypedResponse
|
||||||
} from "@actions/http-client/interfaces";
|
} from "@actions/http-client/interfaces";
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as stream from "stream";
|
||||||
|
import * as util from "util";
|
||||||
|
|
||||||
import { SocketTimeout } from "./constants";
|
import { SocketTimeout } from "./constants";
|
||||||
import {
|
import {
|
||||||
|
@ -109,13 +111,10 @@ export async function getCacheEntry(
|
||||||
|
|
||||||
async function pipeResponseToStream(
|
async function pipeResponseToStream(
|
||||||
response: IHttpClientResponse,
|
response: IHttpClientResponse,
|
||||||
stream: NodeJS.WritableStream
|
output: NodeJS.WritableStream
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return new Promise(resolve => {
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
response.message.pipe(stream).on("close", () => {
|
await pipeline(response.message, output);
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadCache(
|
export async function downloadCache(
|
||||||
|
|
Loading…
Reference in a new issue