Skip to content

Commit 7b859e7

Browse files
committed
Fix(#52): DB parent path not found
1 parent 2295293 commit 7b859e7

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Build/constants/dir.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import path from 'node:path';
22

33
export const ROOT_DIR = path.resolve(__dirname, '../..');
44

5+
export const CACHE_DIR = path.resolve(ROOT_DIR, '.cache');
6+
57
export const SOURCE_DIR = path.join(ROOT_DIR, 'Source');
68

79
export const PUBLIC_DIR = path.resolve(ROOT_DIR, 'public');

Build/lib/cache-filesystem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Custom304NotModifiedError, CustomAbortError, CustomNoETagFallbackError,
1818

1919
import type { IncomingHttpHeaders } from 'undici/types/header';
2020
import { Headers } from 'undici';
21-
import { ROOT_DIR } from '../constants/dir';
21+
import { CACHE_DIR } from '../constants/dir';
2222

2323
export interface CacheOptions<S = string> {
2424
/** Path to sqlite file dir */
@@ -430,7 +430,7 @@ export class Cache<S = string> {
430430
}
431431
}
432432

433-
export const fsFetchCache = new Cache({ cachePath: path.resolve(ROOT_DIR, '.cache') });
433+
export const fsFetchCache = new Cache({ cachePath: CACHE_DIR });
434434
// process.on('exit', () => {
435435
// fsFetchCache.destroy();
436436
// });

Build/lib/fetch-retry.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export type UndiciResponseData<T = unknown> = Dispatcher.ResponseData<T>;
1616

1717
import { inspect } from 'node:util';
1818
import path from 'node:path';
19-
import { ROOT_DIR } from '../constants/dir';
19+
import fs from 'node:fs';
20+
import { CACHE_DIR } from '../constants/dir';
21+
22+
if (!fs.existsSync(CACHE_DIR)) {
23+
fs.mkdirSync(CACHE_DIR, { recursive: true });
24+
}
2025

2126
const agent = new Agent({});
2227

@@ -106,7 +111,7 @@ setGlobalDispatcher(agent.compose(
106111
}),
107112
interceptors.cache({
108113
store: new BetterSqlite3CacheStore({
109-
location: path.join(ROOT_DIR, '.cache/undici-better-sqlite3-cache-store.db'),
114+
location: path.join(CACHE_DIR, 'undici-better-sqlite3-cache-store.db'),
110115
maxEntrySize: 1024 * 1024 * 50 // 50 MiB
111116
})
112117
})

0 commit comments

Comments
 (0)