From 0b4a0a4930cf5e0d46b1976c2a496dd9e7335652 Mon Sep 17 00:00:00 2001 From: Caleb Gosiak Date: Thu, 30 Sep 2021 18:56:21 -0500 Subject: [PATCH] v0.10.0 --- dist/restore/index.js | 12 ++++++++---- dist/save/index.js | 12 ++++++++---- package.json | 2 +- src/cache.service.ts | 13 +++++++++---- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 3445986..399aa19 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -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; diff --git a/dist/save/index.js b/dist/save/index.js index 45e4a5d..3756278 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -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; diff --git a/package.json b/package.json index a2d80e4..a555b02 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/cache.service.ts b/src/cache.service.ts index 9f0925a..a52760c 100644 --- a/src/cache.service.ts +++ b/src/cache.service.ts @@ -38,7 +38,7 @@ export class CacheService { restoreKeys: string[] ): Promise { 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 { + 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, "-"); + } }