This commit is contained in:
Caleb Gosiak 2021-09-30 18:56:21 -05:00
parent 9d956bc62d
commit 0b4a0a4930
4 changed files with 26 additions and 13 deletions

12
dist/restore/index.js vendored
View file

@ -43295,7 +43295,7 @@ class CacheService {
restoreCache(paths, primaryKey, restoreKeys) {
return __awaiter(this, void 0, void 0, function* () {
restoreKeys = restoreKeys || [];
const keys = [primaryKey, ...restoreKeys];
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
core.debug("Resolved Keys:");
core.debug(JSON.stringify(keys));
const compressionMethod = yield utils.getCompressionMethod();
@ -43331,6 +43331,7 @@ class CacheService {
}
saveCache(paths, key) {
return __awaiter(this, void 0, void 0, function* () {
const formattedKey = this.formatKey(key);
const compressionMethod = yield utils.getCompressionMethod();
const cachePaths = yield utils.resolvePaths(paths);
core.debug("Cache Paths:");
@ -43344,8 +43345,8 @@ class CacheService {
yield tar_1.listTar(archivePath, compressionMethod);
}
core.info(`Archive Size: ${filesize_1.default(fs_1.default.statSync(archivePath).size)}`);
core.debug(`Saving Cache (ID: ${key})`);
yield this.uploadToS3(key, archivePath);
core.debug(`Saving Cache (ID: ${formattedKey})`);
yield this.uploadToS3(formattedKey, archivePath);
}
finally {
// Try to delete the archive to save space
@ -43356,7 +43357,7 @@ class CacheService {
core.debug(`Failed to delete archive: ${error}`);
}
}
return key;
return formattedKey;
});
}
uploadToS3(key, archivePath) {
@ -43451,6 +43452,9 @@ class CacheService {
.replace("/", "-")
.toLowerCase();
}
formatKey(key) {
return key.replace(/[^\w\s]/gi, "-");
}
}
exports.CacheService = CacheService;

12
dist/save/index.js vendored
View file

@ -43295,7 +43295,7 @@ class CacheService {
restoreCache(paths, primaryKey, restoreKeys) {
return __awaiter(this, void 0, void 0, function* () {
restoreKeys = restoreKeys || [];
const keys = [primaryKey, ...restoreKeys];
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
core.debug("Resolved Keys:");
core.debug(JSON.stringify(keys));
const compressionMethod = yield utils.getCompressionMethod();
@ -43331,6 +43331,7 @@ class CacheService {
}
saveCache(paths, key) {
return __awaiter(this, void 0, void 0, function* () {
const formattedKey = this.formatKey(key);
const compressionMethod = yield utils.getCompressionMethod();
const cachePaths = yield utils.resolvePaths(paths);
core.debug("Cache Paths:");
@ -43344,8 +43345,8 @@ class CacheService {
yield tar_1.listTar(archivePath, compressionMethod);
}
core.info(`Archive Size: ${filesize_1.default(fs_1.default.statSync(archivePath).size)}`);
core.debug(`Saving Cache (ID: ${key})`);
yield this.uploadToS3(key, archivePath);
core.debug(`Saving Cache (ID: ${formattedKey})`);
yield this.uploadToS3(formattedKey, archivePath);
}
finally {
// Try to delete the archive to save space
@ -43356,7 +43357,7 @@ class CacheService {
core.debug(`Failed to delete archive: ${error}`);
}
}
return key;
return formattedKey;
});
}
uploadToS3(key, archivePath) {
@ -43451,6 +43452,9 @@ class CacheService {
.replace("/", "-")
.toLowerCase();
}
formatKey(key) {
return key.replace(/[^\w\s]/gi, "-");
}
}
exports.CacheService = CacheService;

View file

@ -1,6 +1,6 @@
{
"name": "cache",
"version": "0.9.0",
"version": "0.10.0",
"private": true,
"description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js",

View file

@ -38,7 +38,7 @@ export class CacheService {
restoreKeys: string[]
): Promise<string | undefined> {
restoreKeys = restoreKeys || [];
const keys = [primaryKey, ...restoreKeys];
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
core.debug("Resolved Keys:");
core.debug(JSON.stringify(keys));
@ -85,6 +85,7 @@ export class CacheService {
}
async saveCache(paths: string[], key: string): Promise<string> {
const formattedKey: string = this.formatKey(key);
const compressionMethod = await utils.getCompressionMethod();
const cachePaths = await utils.resolvePaths(paths);
@ -109,8 +110,8 @@ export class CacheService {
`Archive Size: ${filesize(fs.statSync(archivePath).size)}`
);
core.debug(`Saving Cache (ID: ${key})`);
await this.uploadToS3(key, archivePath);
core.debug(`Saving Cache (ID: ${formattedKey})`);
await this.uploadToS3(formattedKey, archivePath);
} finally {
// Try to delete the archive to save space
try {
@ -120,7 +121,7 @@ export class CacheService {
}
}
return key;
return formattedKey;
}
private async uploadToS3(
@ -218,4 +219,8 @@ export class CacheService {
.replace("/", "-")
.toLowerCase();
}
private formatKey(key: string): string {
return key.replace(/[^\w\s]/gi, "-");
}
}