1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2024-11-10 05:23:18 +01: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

18
dist/restore/index.js vendored
View file

@ -2186,6 +2186,8 @@ const http_client_1 = __webpack_require__(539);
const auth_1 = __webpack_require__(226); const auth_1 = __webpack_require__(226);
const crypto = __importStar(__webpack_require__(417)); const crypto = __importStar(__webpack_require__(417));
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const stream = __importStar(__webpack_require__(794));
const util = __importStar(__webpack_require__(669));
const constants_1 = __webpack_require__(694); const constants_1 = __webpack_require__(694);
const utils = __importStar(__webpack_require__(443)); const utils = __importStar(__webpack_require__(443));
const versionSalt = "1.0"; const versionSalt = "1.0";
@ -2271,13 +2273,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) {
@ -4662,6 +4661,13 @@ run();
exports.default = run; exports.default = run;
/***/ }),
/***/ 794:
/***/ (function(module) {
module.exports = require("stream");
/***/ }), /***/ }),
/***/ 826: /***/ 826:

18
dist/save/index.js vendored
View file

@ -2186,6 +2186,8 @@ const http_client_1 = __webpack_require__(539);
const auth_1 = __webpack_require__(226); const auth_1 = __webpack_require__(226);
const crypto = __importStar(__webpack_require__(417)); const crypto = __importStar(__webpack_require__(417));
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const stream = __importStar(__webpack_require__(794));
const util = __importStar(__webpack_require__(669));
const constants_1 = __webpack_require__(694); const constants_1 = __webpack_require__(694);
const utils = __importStar(__webpack_require__(443)); const utils = __importStar(__webpack_require__(443));
const versionSalt = "1.0"; const versionSalt = "1.0";
@ -2271,13 +2273,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) {
@ -4641,6 +4640,13 @@ module.exports = require("fs");
/***/ }), /***/ }),
/***/ 794:
/***/ (function(module) {
module.exports = require("stream");
/***/ }),
/***/ 826: /***/ 826:
/***/ (function(module, __unusedexports, __webpack_require__) { /***/ (function(module, __unusedexports, __webpack_require__) {

View file

@ -8,6 +8,8 @@ import {
} from "@actions/http-client/interfaces"; } from "@actions/http-client/interfaces";
import * as crypto from "crypto"; import * as crypto from "crypto";
import * as fs from "fs"; import * as fs from "fs";
import * as stream from "stream";
import * as util from "util";
import { Inputs, SocketTimeout } from "./constants"; import { Inputs, SocketTimeout } from "./constants";
import { import {
@ -128,13 +130,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(