From 6b6b67a31c89b8bfc411b7d227b43aa8f7f29bcf Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 19 Sep 2026 15:46:09 +0200 Subject: [PATCH] revert --- config.example.json | 3 +-- config.schema.json | 5 ----- src/config.ts | 13 ++----------- src/lib/storage.ts | 6 ++---- src/routes/upload.ts | 3 +-- tests/config.test.ts | 6 ++---- tests/storage.test.ts | 4 ++-- 7 files changed, 10 insertions(+), 30 deletions(-) diff --git a/config.example.json b/config.example.json index 8118b22..b7ceeea 100644 --- a/config.example.json +++ b/config.example.json @@ -15,8 +15,7 @@ "label": "Vidéos", "dir": "./uploads/videos", "allowDirectories": true, - "allowedMimeTypes": ["video/*"], - "permissions": "0666" + "allowedMimeTypes": ["video/*"] }, { "name": "divers", "label": "Divers", "dir": "./uploads/divers" } ], diff --git a/config.schema.json b/config.schema.json index 480a44c..d810a73 100644 --- a/config.schema.json +++ b/config.schema.json @@ -48,11 +48,6 @@ } } ] - }, - "permissions":{ - "type":"string", - "default":"0666", - "description": "Mode d'écriture sur le disque" } } } diff --git a/src/config.ts b/src/config.ts index 2090395..d93f644 100644 --- a/src/config.ts +++ b/src/config.ts @@ -60,12 +60,6 @@ export interface DropTarget { * valeur globale `allowedMimeTypes`. Toujours résolu après parsing. */ allowedMimeTypes: MimePolicy; - - /** - * Mode de permission d'écriture - * Par défaut 0o666 - */ - permission: number; } /** Liste non vide de cibles de dépôt ; la première est la cible par défaut. */ @@ -391,8 +385,7 @@ function parseTargets(value: unknown, defaultMimePolicy: MimePolicy): DropTarget allowedMimeTypes: raw.allowedMimeTypes === undefined || raw.allowedMimeTypes === null ? defaultMimePolicy - : parseMimePolicy(raw.allowedMimeTypes, `targets[${String(index)}].allowedMimeTypes`), - permission: parseInt(optionalString(raw.permission, `targets[${String(index)}].permission`) ?? "0666",8) + : parseMimePolicy(raw.allowedMimeTypes, `targets[${String(index)}].allowedMimeTypes`) }; }; @@ -450,7 +443,5 @@ export function loadConfig(env: NodeJS.ProcessEnv): AppConfig { throw new ConfigError(`JSON invalide dans ${file}`, { cause }); } - const parsedConfig = parseConfig(raw); - console.log(JSON.stringify(parsedConfig,undefined,2)) - return parsedConfig; + return parseConfig(raw); } diff --git a/src/lib/storage.ts b/src/lib/storage.ts index 8356132..c744c51 100644 --- a/src/lib/storage.ts +++ b/src/lib/storage.ts @@ -33,8 +33,6 @@ export interface SaveFileParams { /** Dossier de destination (résolu depuis la cible de dépôt choisie). */ targetDir: string; maxFileSizeBytes: number; - /** Permission d'écriture */ - permission:number; /** * Mode dossier : recrée `segments` sous `targetDir` et conserve `fileName` ; * un fichier existant au même chemin est écrasé. Absent -> nom dérivé unique @@ -146,7 +144,7 @@ export async function resolveDestination(input: DestinationInput): Promise { - const { source, originalName, mimeType, maxFileSizeBytes,permission } = params; + const { source, originalName, mimeType, maxFileSizeBytes } = params; const { storedName, destination } = await resolveDestination(params); let bytesWritten = 0; @@ -165,7 +163,7 @@ export async function saveFile(params: SaveFileParams): Promise { await pipeline( source, limiter, - createWriteStream(destination, { highWaterMark: WRITE_HIGH_WATER_MARK ,mode:permission}), + createWriteStream(destination, { highWaterMark: WRITE_HIGH_WATER_MARK ,mode:0o777}), ); } catch (error) { await rm(destination, { force: true }); diff --git a/src/routes/upload.ts b/src/routes/upload.ts index 980bf03..edea859 100644 --- a/src/routes/upload.ts +++ b/src/routes/upload.ts @@ -93,8 +93,7 @@ export const uploadRoutes: FastifyPluginCallback = (app, _options, done) => { mimeType: part.mimetype, targetDir: target.dir, maxFileSizeBytes: app.appConfig.maxFileSizeBytes, - ...(placement !== undefined ? { placement } : {}), - permission:target.permission + ...(placement !== undefined ? { placement } : {}) }); app.notifier.uploadCompleted({ diff --git a/tests/config.test.ts b/tests/config.test.ts index 896b4be..056c43b 100644 --- a/tests/config.test.ts +++ b/tests/config.test.ts @@ -39,8 +39,7 @@ describe('parseConfig', () => { label: 'photos', dir: './uploads/photos', allowDirectories: false, - allowedMimeTypes: DEFAULT_ALLOWED_MIME, - permission:0o666 + allowedMimeTypes: DEFAULT_ALLOWED_MIME }, ]); expect(config.targets[0]?.allowedMimeTypes).toBe(DEFAULT_ALLOWED_MIME); @@ -97,8 +96,7 @@ describe('parseConfig', () => { label: 'X', dir: './x', allowDirectories: false, - allowedMimeTypes: DEFAULT_ALLOWED_MIME, - permission:0o666 + allowedMimeTypes: DEFAULT_ALLOWED_MIME }); expect( parseConfig({ ...BASE, targets: [{ name: 'x', dir: './x', allowDirectories: true }] }) diff --git a/tests/storage.test.ts b/tests/storage.test.ts index 8e346f5..7614874 100644 --- a/tests/storage.test.ts +++ b/tests/storage.test.ts @@ -24,8 +24,8 @@ afterEach(async () => { await removeDir(uploadDir); }); -function params(maxFileSizeBytes = 1024 * 1024): { targetDir: string; maxFileSizeBytes: number,permission:number } { - return { targetDir: uploadDir, maxFileSizeBytes ,permission:0o666}; +function params(maxFileSizeBytes = 1024 * 1024): { targetDir: string; maxFileSizeBytes: number } { + return { targetDir: uploadDir, maxFileSizeBytes }; } describe('saveFile', () => {