mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 08:43:55 +08:00
try this
This commit is contained in:
parent
d9e985924e
commit
2377d067bc
4 changed files with 31 additions and 46 deletions
22
dist/restore/index.js
vendored
22
dist/restore/index.js
vendored
|
@ -43330,20 +43330,14 @@ class CacheService {
|
||||||
uploadToS3(key, archivePath) {
|
uploadToS3(key, archivePath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const client = new aws_sdk_1.S3();
|
const client = new aws_sdk_1.S3();
|
||||||
// Read in the file, convert it to base64, store to S3
|
const data = fs_1.default.readFileSync(archivePath).toString("base64");
|
||||||
fs_1.default.readFile(archivePath, (err, data) => {
|
return client
|
||||||
if (err) {
|
.putObject({
|
||||||
throw err;
|
Bucket: this._bucket,
|
||||||
}
|
Key: key,
|
||||||
const base64data = data.toString("base64");
|
Body: data
|
||||||
client
|
})
|
||||||
.putObject({
|
.promise();
|
||||||
Bucket: this._bucket,
|
|
||||||
Key: key,
|
|
||||||
Body: base64data
|
|
||||||
})
|
|
||||||
.send();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
dist/save/index.js
vendored
22
dist/save/index.js
vendored
|
@ -43330,20 +43330,14 @@ class CacheService {
|
||||||
uploadToS3(key, archivePath) {
|
uploadToS3(key, archivePath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const client = new aws_sdk_1.S3();
|
const client = new aws_sdk_1.S3();
|
||||||
// Read in the file, convert it to base64, store to S3
|
const data = fs_1.default.readFileSync(archivePath).toString("base64");
|
||||||
fs_1.default.readFile(archivePath, (err, data) => {
|
return client
|
||||||
if (err) {
|
.putObject({
|
||||||
throw err;
|
Bucket: this._bucket,
|
||||||
}
|
Key: key,
|
||||||
const base64data = data.toString("base64");
|
Body: data
|
||||||
client
|
})
|
||||||
.putObject({
|
.promise();
|
||||||
Bucket: this._bucket,
|
|
||||||
Key: key,
|
|
||||||
Body: base64data
|
|
||||||
})
|
|
||||||
.send();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Cache dependencies and build outputs",
|
"description": "Cache dependencies and build outputs",
|
||||||
"main": "dist/restore/index.js",
|
"main": "dist/restore/index.js",
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import * as utils from "@actions/cache/lib/internal/cacheUtils";
|
import * as utils from "@actions/cache/lib/internal/cacheUtils";
|
||||||
import { createTar, listTar } from "@actions/cache/lib/internal/tar";
|
import { createTar, listTar } from "@actions/cache/lib/internal/tar";
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import { S3 } from "aws-sdk";
|
import { AWSError, S3 } from "aws-sdk";
|
||||||
|
import { PromiseResult } from "aws-sdk/lib/request";
|
||||||
import filesize from "filesize";
|
import filesize from "filesize";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
@ -73,23 +74,19 @@ export class CacheService {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async uploadToS3(key: string, archivePath: string): Promise<void> {
|
private async uploadToS3(
|
||||||
|
key: string,
|
||||||
|
archivePath: string
|
||||||
|
): Promise<PromiseResult<S3.PutObjectOutput, AWSError>> {
|
||||||
const client = new S3();
|
const client = new S3();
|
||||||
// Read in the file, convert it to base64, store to S3
|
const data = fs.readFileSync(archivePath).toString("base64");
|
||||||
fs.readFile(archivePath, (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
const base64data = data.toString("base64");
|
return client
|
||||||
|
.putObject({
|
||||||
client
|
Bucket: this._bucket,
|
||||||
.putObject({
|
Key: key,
|
||||||
Bucket: this._bucket,
|
Body: data
|
||||||
Key: key,
|
})
|
||||||
Body: base64data
|
.promise();
|
||||||
})
|
|
||||||
.send();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue