1
0
Fork 0
mirror of https://github.com/actions/cache.git synced 2025-07-16 21:27:54 +00:00
This commit is contained in:
Caleb Gosiak 2021-09-30 19:28:38 -05:00
parent 0b4a0a4930
commit 7b3fb19462
5 changed files with 28 additions and 22 deletions

View file

@ -12,6 +12,8 @@ import filesize from "filesize";
import fs from "fs";
import * as path from "path";
import { formatKey } from "./utils/actionUtils";
export class CacheService {
private _client: S3;
private _bucket: string;
@ -38,7 +40,7 @@ export class CacheService {
restoreKeys: string[]
): Promise<string | undefined> {
restoreKeys = restoreKeys || [];
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
const keys = [primaryKey, ...restoreKeys].map(x => formatKey(x));
core.debug("Resolved Keys:");
core.debug(JSON.stringify(keys));
@ -85,7 +87,7 @@ export class CacheService {
}
async saveCache(paths: string[], key: string): Promise<string> {
const formattedKey: string = this.formatKey(key);
const formattedKey: string = formatKey(key);
const compressionMethod = await utils.getCompressionMethod();
const cachePaths = await utils.resolvePaths(paths);
@ -219,8 +221,4 @@ export class CacheService {
.replace("/", "-")
.toLowerCase();
}
private formatKey(key: string): string {
return key.replace(/[^\w\s]/gi, "-");
}
}