From 77d918fbe0a09befd29668dc74ca40dcfbfbf58e Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Fri, 20 Mar 2026 17:28:09 +0100 Subject: [PATCH] fix: path --- server/auth.ts | 4 ++-- server/config.ts | 2 +- server/index.ts | 4 ++-- server/logger.ts | 4 ++-- server/organize-worker.ts | 8 ++++---- server/secret.ts | 4 ++-- server/settings.ts | 4 ++-- server/torrent-clients/index.ts | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/server/auth.ts b/server/auth.ts index 20b0035..7831cd0 100644 --- a/server/auth.ts +++ b/server/auth.ts @@ -4,9 +4,9 @@ import bcrypt from 'bcryptjs' import jwt from 'jsonwebtoken' import type { Request, Response, NextFunction } from 'express' import { JWT_SECRET } from './secret.js' -import { BASE_DIR } from './config.js' +import { DATA_DIR } from './config.js' -const DATA_PATH = path.join(BASE_DIR, 'config', 'auth.json') +const DATA_PATH = path.join(DATA_DIR, 'config', 'auth.json') const SALT_ROUNDS = 10 interface AuthData { diff --git a/server/config.ts b/server/config.ts index a4f47b1..5520130 100644 --- a/server/config.ts +++ b/server/config.ts @@ -10,4 +10,4 @@ export const BASE_DIR = _isBunBinary export const DATA_DIR = fs.existsSync('/.dockerenv') ? '/config' - : path.join(BASE_DIR, 'data') \ No newline at end of file + : path.join(BASE_DIR, 'config') \ No newline at end of file diff --git a/server/index.ts b/server/index.ts index 5340b18..0a532a5 100644 --- a/server/index.ts +++ b/server/index.ts @@ -12,7 +12,7 @@ import { import qbittorrentDriver from './torrent-clients/qbittorrent.js' import { organizeTorrent, autoOrganizeAll, scanMediaPath } from './organize.js' import { logger, readLogs, clearLogs, logsFileSize } from './logger.js' -import { DATA_DIR, BASE_DIR, _isBunBinary } from './config.js' +import { DATA_DIR, BASE_DIR } from './config.js' registerDriver(qbittorrentDriver) @@ -403,7 +403,7 @@ app.get('/api/downloads', requireAuth, async (_req, res) => { let torrentFinal: any[] = [] try { - const tfPath = path.join(BASE_DIR, 'config', 'torrent_final.json') + const tfPath = path.join(DATA_DIR, 'config', 'torrent_final.json') if (fs.existsSync(tfPath)) torrentFinal = JSON.parse(fs.readFileSync(tfPath, 'utf-8')) } catch {} diff --git a/server/logger.ts b/server/logger.ts index e1d6cd9..b5bf2db 100644 --- a/server/logger.ts +++ b/server/logger.ts @@ -8,7 +8,7 @@ import fs from 'fs' import path from 'path' -import { BASE_DIR } from './config.js' +import { DATA_DIR } from './config.js' export type LogLevel = 'debug' | 'info' | 'warn' | 'error' @@ -20,7 +20,7 @@ export interface LogEntry { meta? : Record } -const LOGS_PATH = path.join(BASE_DIR, 'config', 'logs.jsonl') +const LOGS_PATH = path.join(DATA_DIR, 'config', 'logs.jsonl') const MAX_LINES = 2000 // rotation auto au-delà const IS_PROD = process.env.NODE_ENV === 'production' diff --git a/server/organize-worker.ts b/server/organize-worker.ts index 14681cd..d2ba424 100644 --- a/server/organize-worker.ts +++ b/server/organize-worker.ts @@ -15,10 +15,10 @@ import fs from 'fs' import fsp from 'fs/promises' import path from 'path' import { parentPort } from 'worker_threads' -import { BASE_DIR, _isBunBinary } from './config.js' +import { DATA_DIR } from './config.js' -const TORRENTS_PATH = path.join(BASE_DIR, 'config', 'torrent_final.json') -const ORGANIZED_PATH = path.join(BASE_DIR, 'config', 'organized.json') +const TORRENTS_PATH = path.join(DATA_DIR, 'config', 'torrent_final.json') +const ORGANIZED_PATH = path.join(DATA_DIR, 'config', 'organized.json') // ─── Utils log ──────────────────────────────────────────────── // Le worker tourne dans un thread séparé — il passe les logs au thread principal @@ -33,7 +33,7 @@ function debug(msg: string) { parentPort?.postMessage({ type: 'log', level: 'deb function readSettings(): { mediaPath: string; completePath: string; organizeMode: string; nfoSupport: boolean } { try { - const p = path.join(BASE_DIR, 'config', 'settings.json') + const p = path.join(DATA_DIR, 'config', 'settings.json') if (!fs.existsSync(p)) return { mediaPath: '', completePath: '', organizeMode: 'hardlink', nfoSupport: false } return JSON.parse(fs.readFileSync(p, 'utf-8')) } catch { return { mediaPath: '', completePath: '', organizeMode: 'hardlink', nfoSupport: false } } diff --git a/server/secret.ts b/server/secret.ts index ec51195..5c35059 100644 --- a/server/secret.ts +++ b/server/secret.ts @@ -9,9 +9,9 @@ import fs from 'fs' import path from 'path' import crypto from 'crypto' -import { BASE_DIR } from './config.js' +import { DATA_DIR } from './config.js' -const SECRET_PATH = path.join(BASE_DIR, 'config', 'secret.key') +const SECRET_PATH = path.join(DATA_DIR, 'config', 'secret.key') function generateSecret(): string { return crypto.randomBytes(48).toString('hex') diff --git a/server/settings.ts b/server/settings.ts index fdbd971..a9cdd07 100644 --- a/server/settings.ts +++ b/server/settings.ts @@ -1,8 +1,8 @@ import fs from 'fs' import path from 'path' -import { BASE_DIR, _isBunBinary } from './config.js' +import { DATA_DIR } from './config.js' -const DATA_PATH = path.join(BASE_DIR, 'config', 'settings.json') +const DATA_PATH = path.join(DATA_DIR, 'config', 'settings.json') export interface Settings { mediaPath : string diff --git a/server/torrent-clients/index.ts b/server/torrent-clients/index.ts index f4700ff..c29cac2 100644 --- a/server/torrent-clients/index.ts +++ b/server/torrent-clients/index.ts @@ -9,7 +9,7 @@ import { randomUUID } from 'crypto' import fs from 'fs' import path from 'path' -import { BASE_DIR } from '../config.js' +import { DATA_DIR } from '../config.js' // ─── Types ──────────────────────────────────────────────────────────────────── @@ -78,7 +78,7 @@ export function getAvailableClients(): TorrentClientDefinition[] { // ─── Persistence (clients enregistrés) ──────────────────────────────────────── -const CLIENTS_PATH = path.join(BASE_DIR, 'config', 'torrent_clients.json') +const CLIENTS_PATH = path.join(DATA_DIR, 'config', 'torrent_clients.json') function loadClients(): SavedClient[] { try {