diff --git a/src/services/diskCache.ts b/src/services/diskCache.ts index 8835b5f83..b6771fbbe 100644 --- a/src/services/diskCache.ts +++ b/src/services/diskCache.ts @@ -1,6 +1,6 @@ import DiskLRUService from '../services/diskLRU'; import crypto from 'crypto'; -import { existsSync, readFile, writeFile } from 'promise-fs'; +import { existsSync, readFile, writeFile, unlink } from 'promise-fs'; import path from 'path'; const MAX_CACHE_SIZE = 1000 * 1000 * 1000; // 1GB @@ -29,6 +29,15 @@ export class DiskCache { return undefined; } } + async delete(cacheKey: string): Promise { + const cachePath = getAssetCachePath(this.cacheBucketDir, cacheKey); + if (existsSync(cachePath)) { + await unlink(cachePath); + return true; + } else { + return false; + } + } } function getAssetCachePath(cacheDir: string, cacheKey: string) { // hashing the key to prevent illegal filenames