rename
This commit is contained in:
parent
421efaaa6c
commit
d52fe6925c
|
@ -23,7 +23,7 @@ class DiskCache {
|
||||||
constructor(private cacheBucketDir: string) {}
|
constructor(private cacheBucketDir: string) {}
|
||||||
|
|
||||||
async put(cacheKey: string, response: Response): Promise<void> {
|
async put(cacheKey: string, response: Response): Promise<void> {
|
||||||
const cachePath = makeAssetCachePath(this.cacheBucketDir, cacheKey);
|
const cachePath = getAssetCachePath(this.cacheBucketDir, cacheKey);
|
||||||
await writeFile(
|
await writeFile(
|
||||||
cachePath,
|
cachePath,
|
||||||
new Uint8Array(await response.arrayBuffer())
|
new Uint8Array(await response.arrayBuffer())
|
||||||
|
@ -31,7 +31,7 @@ class DiskCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
async match(cacheKey: string): Promise<Response> {
|
async match(cacheKey: string): Promise<Response> {
|
||||||
const cachePath = makeAssetCachePath(this.cacheBucketDir, cacheKey);
|
const cachePath = getAssetCachePath(this.cacheBucketDir, cacheKey);
|
||||||
if (existsSync(cachePath)) {
|
if (existsSync(cachePath)) {
|
||||||
return new Response(await readFile(cachePath));
|
return new Response(await readFile(cachePath));
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,7 +40,7 @@ class DiskCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeAssetCachePath(cacheDir: string, cacheKey: string) {
|
function getAssetCachePath(cacheDir: string, cacheKey: string) {
|
||||||
// hashing the key to prevent illegal filenames
|
// hashing the key to prevent illegal filenames
|
||||||
const cacheKeyHash = crypto
|
const cacheKeyHash = crypto
|
||||||
.createHash('sha256')
|
.createHash('sha256')
|
||||||
|
|
Loading…
Reference in a new issue