Refactor: use ROOT_DIR

This commit is contained in:
SukkaW
2025-01-10 20:22:30 +08:00
parent 57dc1b6787
commit 8340a0f4f5
6 changed files with 12 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ import { Custom304NotModifiedError, CustomAbortError, CustomNoETagFallbackError,
import type { IncomingHttpHeaders } from 'undici/types/header';
import { Headers } from 'undici';
import { ROOT_DIR } from '../constants/dir';
export interface CacheOptions<S = string> {
/** Path to sqlite file dir */
@@ -429,13 +430,11 @@ export class Cache<S = string> {
}
}
export const fsFetchCache = new Cache({ cachePath: path.resolve(__dirname, '../../.cache') });
export const fsFetchCache = new Cache({ cachePath: path.resolve(ROOT_DIR, '.cache') });
// process.on('exit', () => {
// fsFetchCache.destroy();
// });
// export const fsCache = traceSync('initializing filesystem cache', () => new Cache<Uint8Array>({ cachePath: path.resolve(__dirname, '../../.cache'), type: 'buffer' }));
const separator = '\u0000';
export const serializeSet = (set: Set<string>) => fastStringArrayJoin(Array.from(set), separator);
export const deserializeSet = (str: string) => new Set(str.split(separator));