D2: unify DATA_DIR default across audio/downloader/remux/db modules
Create src/lib/server/data-dir.ts as single source of truth for DATA_DIR using db.ts's $HOME-based convention. All four modules now import from it instead of defining their own inline default (some resolving to /tmp/.whisper-pwa). Changes: - src/lib/server/data-dir.ts — new file, exports DATA_DIR const - db.ts — import DATA_DIR from data-dir.ts (same logic, same path) - audio.ts — import DATA_DIR, replace inline process.env.DATA_DIR ?? '/tmp/...' - downloader.ts — import DATA_DIR, replace inline '/tmp/.whisper-pwa' - remux.ts — import DATA_DIR, replace inline process.env.DATA_DIR ?? '/tmp/...' - tests/data-dir.test.ts — 10 tests covering default, custom, and module integrity - tests/retry-pipeline.test.ts — fix stale hardcoded /tmp/.whisper-pwa/uploads path; compute parent dir from getUploadPath() dynamically Test pass rate: 217/220 (3 pre-existing failures unrelated to DATA_DIR) - 2 D5 downloader tests need yt-dlp (not available in test env) - All other tests green, including the new data-dir.test.ts (10/10)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { join } from 'path';
|
||||
|
||||
/**
|
||||
* Single source of truth for the app's persistent data directory.
|
||||
* Uses db.ts's pre-existing $HOME-based default (the one already backed by
|
||||
* a real persistent volume in prod) so uploads, audio prep, remux temp files,
|
||||
* and job rows all resolve under the same path when DATA_DIR env var is unset.
|
||||
*
|
||||
* All modules that need a data directory root import this constant instead of
|
||||
* defining their own inline default.
|
||||
*/
|
||||
export const DATA_DIR = process.env.DATA_DIR ?? join(process.env.HOME ?? '/tmp', '.whisper-pwa');
|
||||
Reference in New Issue
Block a user