Multi-Hoster-Upload/lib/log-policy.js
Administrator 57f8f0876e feat(log): per-hoster toggle for writing links to fileuploader.log
New per-hoster setting "Links in Log schreiben" (logToFile, default
on). When unchecked for a hoster, that hoster's successful upload
links are no longer written to fileuploader.log — other hosters keep
logging independently.

- lib/config-store.js: logToFile: true added to HOSTER_SETTINGS_DEFAULTS;
  merge-on-load gives every hoster the key (old configs included).
- renderer/app.js: checkbox per hoster panel + collection loop now
  handles type=checkbox (boolean) alongside the numeric fields. The
  autosave bind already special-cased checkboxes (change event).
- lib/log-policy.js (new): hosterLogToFileEnabled() — pure, opt-out
  semantics. Only an explicit logToFile===false disables; missing/
  malformed/non-true values all default ON so links are never
  silently dropped.
- main.js: shouldLogHosterToFile() reads the LIVE uploadManager
  .hosterSettings (so a mid-batch toggle takes effect at once), falls
  back to persisted config, then to enabled. Guards appendUploadLog
  in the done handler; skipped writes get a debugLog line.

Tests: 8 log-policy (defaults, opt-out, per-hoster independence,
malformed input) + 2 config-store (default true, persisted false
survives reload). 147/147 green, eslint clean.
2026-05-23 15:29:25 +02:00

18 lines
808 B
JavaScript

// Per-hoster upload-log policy. Decides whether a hoster's successful upload
// links get written to fileuploader.log. Pure + dependency-free so it's
// trivially unit-testable and shared between the runtime decision and tests.
//
// Contract: logging is ON unless the hoster's settings explicitly set
// logToFile === false. Missing settings / missing hoster / malformed input
// all default to ON, so the feature is strictly opt-out and never silently
// drops links because a config key wasn't present.
function hosterLogToFileEnabled(hosterSettings, hoster) {
if (!hosterSettings || typeof hosterSettings !== 'object') return true;
const hs = hosterSettings[hoster];
if (!hs || typeof hs !== 'object') return true;
return hs.logToFile !== false;
}
module.exports = { hosterLogToFileEnabled };