Skip to content

Commit

Permalink
fix: do not use presign
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Nov 10, 2023
1 parent 1da9e42 commit b664080
Show file tree
Hide file tree
Showing 13 changed files with 12,553 additions and 26,837 deletions.
19,671 changes: 6,272 additions & 13,399 deletions dist/restore/index.js

Large diffs are not rendered by default.

Binary file modified dist/restore/opendal.darwin-arm64.node
Binary file not shown.
Binary file modified dist/restore/opendal.darwin-x64.node
Binary file not shown.
Binary file modified dist/restore/opendal.linux-x64-gnu.node
Binary file not shown.
Binary file modified dist/restore/opendal.win32-x64-msvc.node
Binary file not shown.
19,674 changes: 6,272 additions & 13,402 deletions dist/save/index.js

Large diffs are not rendered by default.

Binary file modified dist/save/opendal.darwin-arm64.node
Binary file not shown.
Binary file modified dist/save/opendal.darwin-x64.node
Binary file not shown.
Binary file modified dist/save/opendal.linux-x64-gnu.node
Binary file not shown.
Binary file modified dist/save/opendal.win32-x64-msvc.node
Binary file not shown.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
"dependencies": {
"@actions/cache": "^3.2.2",
"@actions/core": "^1.10.1",
"@opendal/lib-darwin-arm64": "^0.40.0",
"@opendal/lib-darwin-x64": "^0.40.0",
"@opendal/lib-linux-x64-gnu": "^0.40.0",
"@opendal/lib-win32-x64-msvc": "^0.40.0",
"axios": "^1.5.0",
"opendal": "^0.40.0"
"@opendal/lib-darwin-arm64": "^0.41.0",
"@opendal/lib-darwin-x64": "^0.41.0",
"@opendal/lib-linux-x64-gnu": "^0.41.0",
"@opendal/lib-win32-x64-msvc": "^0.41.0",
"opendal": "^0.41.0"
},
"devDependencies": {
"@types/jest": "^26.0.23",
Expand Down
16 changes: 2 additions & 14 deletions src/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
setCacheHitOutput,
saveMatchedKey,
} from "./utils";
import axios from "axios";

process.on("uncaughtException", (e) => core.info("warning: " + e.message));

Expand Down Expand Up @@ -54,19 +53,8 @@ async function restoreCache() {
core.info(
`Downloading cache from ${provider} to ${archivePath}. bucket: ${bucket}, root: ${root}, object: ${obj}`
);
const req = await op.presignRead(obj, 600);

core.debug(`Presigned request Method: ${req.method}, Url: ${req.url}`);
for (const key in req.headers) {
core.debug(`Header: ${key}: ${req.headers[key]}`);
}
const response = await axios({
method: req.method,
url: req.url,
headers: req.headers,
responseType: "stream",
});
await fs.promises.writeFile(archivePath, response.data);
const data = await op.read(obj);
await fs.promises.writeFile(archivePath, data);

if (core.isDebug()) {
await listTar(archivePath, compressionMethod);
Expand Down
18 changes: 2 additions & 16 deletions src/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as core from "@actions/core";
import * as path from "path";
import { State } from "./state";
import { Operator } from "opendal";
import axios from "axios";
import * as fs from "fs";
import {
getInputAsArray,
Expand Down Expand Up @@ -54,21 +53,8 @@ async function saveCache() {
const object = path.posix.join(key, cacheFileName);

core.info(`Uploading tar to ${provider}. Bucket: ${bucket}, root: ${root}, Object: ${object}`);
const data = fs.createReadStream(archivePath);
const req = await op.presignWrite(object, 600);
core.debug(`Presigned request Method: ${req.method}, Url: ${req.url}`);
const headers: Record<string, string> = {};
for (const key in req.headers) {
core.debug(`Header: ${key}: ${req.headers[key]}`);
headers[key] = req.headers[key];
}
headers["Content-Length"] = fs.statSync(archivePath).size.toString();
await axios({
method: req.method,
url: req.url,
headers: headers,
data: data,
});
const data = await fs.promises.readFile(archivePath);
await op.write(object, data);
core.info(`Cache saved to ${provider} successfully`);
} catch (e) {
core.info(`Save ${provider} cache failed: ${e}`);
Expand Down

0 comments on commit b664080

Please sign in to comment.