mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Fix(#52): DB parent path not found
This commit is contained in:
parent
2295293639
commit
7b859e7358
@ -2,6 +2,8 @@ import path from 'node:path';
|
|||||||
|
|
||||||
export const ROOT_DIR = path.resolve(__dirname, '../..');
|
export const ROOT_DIR = path.resolve(__dirname, '../..');
|
||||||
|
|
||||||
|
export const CACHE_DIR = path.resolve(ROOT_DIR, '.cache');
|
||||||
|
|
||||||
export const SOURCE_DIR = path.join(ROOT_DIR, 'Source');
|
export const SOURCE_DIR = path.join(ROOT_DIR, 'Source');
|
||||||
|
|
||||||
export const PUBLIC_DIR = path.resolve(ROOT_DIR, 'public');
|
export const PUBLIC_DIR = path.resolve(ROOT_DIR, 'public');
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import { Custom304NotModifiedError, CustomAbortError, CustomNoETagFallbackError,
|
|||||||
|
|
||||||
import type { IncomingHttpHeaders } from 'undici/types/header';
|
import type { IncomingHttpHeaders } from 'undici/types/header';
|
||||||
import { Headers } from 'undici';
|
import { Headers } from 'undici';
|
||||||
import { ROOT_DIR } from '../constants/dir';
|
import { CACHE_DIR } from '../constants/dir';
|
||||||
|
|
||||||
export interface CacheOptions<S = string> {
|
export interface CacheOptions<S = string> {
|
||||||
/** Path to sqlite file dir */
|
/** Path to sqlite file dir */
|
||||||
@ -430,7 +430,7 @@ export class Cache<S = string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fsFetchCache = new Cache({ cachePath: path.resolve(ROOT_DIR, '.cache') });
|
export const fsFetchCache = new Cache({ cachePath: CACHE_DIR });
|
||||||
// process.on('exit', () => {
|
// process.on('exit', () => {
|
||||||
// fsFetchCache.destroy();
|
// fsFetchCache.destroy();
|
||||||
// });
|
// });
|
||||||
|
|||||||
@ -16,7 +16,12 @@ export type UndiciResponseData<T = unknown> = Dispatcher.ResponseData<T>;
|
|||||||
|
|
||||||
import { inspect } from 'node:util';
|
import { inspect } from 'node:util';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { ROOT_DIR } from '../constants/dir';
|
import fs from 'node:fs';
|
||||||
|
import { CACHE_DIR } from '../constants/dir';
|
||||||
|
|
||||||
|
if (!fs.existsSync(CACHE_DIR)) {
|
||||||
|
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
const agent = new Agent({});
|
const agent = new Agent({});
|
||||||
|
|
||||||
@ -106,7 +111,7 @@ setGlobalDispatcher(agent.compose(
|
|||||||
}),
|
}),
|
||||||
interceptors.cache({
|
interceptors.cache({
|
||||||
store: new BetterSqlite3CacheStore({
|
store: new BetterSqlite3CacheStore({
|
||||||
location: path.join(ROOT_DIR, '.cache/undici-better-sqlite3-cache-store.db'),
|
location: path.join(CACHE_DIR, 'undici-better-sqlite3-cache-store.db'),
|
||||||
maxEntrySize: 1024 * 1024 * 50 // 50 MiB
|
maxEntrySize: 1024 * 1024 * 50 // 50 MiB
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user