|
@@ -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<boolean> {
|
|
|
+ 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
|