Create work directories when settings are saved
This commit is contained in:
+38
-14
@@ -102,6 +102,19 @@ function settingsFingerprint(settings: AppSettings): string {
|
||||
return JSON.stringify(normalizeSettings(settings));
|
||||
}
|
||||
|
||||
const WORK_DIRECTORY_SETTING_KEYS = new Set<keyof AppSettings>([
|
||||
"createWorkDirectoriesOnStartup",
|
||||
"outputDir",
|
||||
"autoExtract",
|
||||
"extractDir",
|
||||
"collectMkvToLibrary",
|
||||
"mkvLibraryDir"
|
||||
]);
|
||||
|
||||
function touchesWorkDirectorySettings(partial: Partial<AppSettings>): boolean {
|
||||
return Object.keys(partial).some((key) => WORK_DIRECTORY_SETTING_KEYS.has(key as keyof AppSettings));
|
||||
}
|
||||
|
||||
type PendingRealDebridWebAccount = {
|
||||
generation: number;
|
||||
dailyLimitBytes: number;
|
||||
@@ -174,13 +187,7 @@ export class AppController {
|
||||
}
|
||||
this.applyNetworkProxyConfiguration();
|
||||
this.initializeLogStorage();
|
||||
const workDirectories = ensureStartupWorkDirectories(this.settings);
|
||||
if (workDirectories.created.length > 0) {
|
||||
logger.info(`Arbeitsordner beim Start angelegt: ${workDirectories.created.map((entry) => entry.kind).join(", ")}`);
|
||||
}
|
||||
for (const failure of workDirectories.failures) {
|
||||
logger.warn(`Arbeitsordner konnte beim Start nicht angelegt werden (${failure.kind}): ${failure.error}`);
|
||||
}
|
||||
this.ensureConfiguredWorkDirectories(this.settings, "beim Start");
|
||||
this.runHistoryLifecycleCleanup("Start", () => resetHistoryForRetention(this.storagePaths, this.settings.historyRetentionMode));
|
||||
const loadResult = loadSessionWithStatus(this.storagePaths);
|
||||
const session = loadResult.session;
|
||||
@@ -702,17 +709,31 @@ export class AppController {
|
||||
return { proxyListRestored, proxyOnlyDisabled };
|
||||
}
|
||||
|
||||
private ensureConfiguredWorkDirectories(settings: AppSettings, trigger: "beim Start" | "nach dem Speichern"): void {
|
||||
const workDirectories = ensureStartupWorkDirectories(settings);
|
||||
if (workDirectories.created.length > 0) {
|
||||
logger.info(`Arbeitsordner ${trigger} angelegt: ${workDirectories.created.map((entry) => entry.kind).join(", ")}`);
|
||||
}
|
||||
for (const failure of workDirectories.failures) {
|
||||
logger.warn(`Arbeitsordner konnte ${trigger} nicht angelegt werden (${failure.kind}): ${failure.error}`);
|
||||
}
|
||||
}
|
||||
|
||||
public updateSettings(partial: Partial<AppSettings>): AppSettings {
|
||||
const sanitizedPatch = sanitizeSettingsPatch(partial);
|
||||
const previousSettings = this.settings;
|
||||
const sanitizedPatch = sanitizeSettingsPatch(partial);
|
||||
const previousSettings = this.settings;
|
||||
const ensureWorkDirectoriesAfterSave = touchesWorkDirectorySettings(sanitizedPatch);
|
||||
let nextSettings = normalizeSettings({
|
||||
...previousSettings,
|
||||
...sanitizedPatch
|
||||
});
|
||||
|
||||
if (settingsFingerprint(nextSettings) === settingsFingerprint(previousSettings)) {
|
||||
return previousSettings;
|
||||
}
|
||||
|
||||
if (settingsFingerprint(nextSettings) === settingsFingerprint(previousSettings)) {
|
||||
if (ensureWorkDirectoriesAfterSave) {
|
||||
this.ensureConfiguredWorkDirectories(previousSettings, "nach dem Speichern");
|
||||
}
|
||||
return previousSettings;
|
||||
}
|
||||
|
||||
if (previousSettings.logStorageLocation !== nextSettings.logStorageLocation
|
||||
&& !this.reconfigureLogStorage(nextSettings.logStorageLocation)) {
|
||||
@@ -743,7 +764,10 @@ export class AppController {
|
||||
this.settings = nextSettings;
|
||||
this.applyNetworkProxyConfiguration();
|
||||
this.manager.setSettings(this.settings);
|
||||
this.audit("INFO", "Einstellungen aktualisiert", {
|
||||
if (ensureWorkDirectoriesAfterSave) {
|
||||
this.ensureConfiguredWorkDirectories(this.settings, "nach dem Speichern");
|
||||
}
|
||||
this.audit("INFO", "Einstellungen aktualisiert", {
|
||||
changedKeys: Object.keys(sanitizedPatch),
|
||||
accountChanges: diffAccountSummary(previousSettings, this.settings)
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ const pairs = [
|
||||
["Sprache", "Language"], ["Speicherort", "Storage location"], ["Download-Verhalten", "Download behavior"], ["Oberfläche und Bedienung", "Interface and controls"], ["Discord-Benachrichtigungen", "Discord notifications"],
|
||||
["Speicherort, Download-Verhalten, Verlauf, Oberfläche und Benachrichtigungen.", "Storage location, download behavior, history, interface and notifications."], ["Hell", "Light"], ["Dunkel", "Dark"],
|
||||
["Download-Ordner", "Download folder"], ["Paketname (optional)", "Package name (optional)"], ["Max. gleichzeitige Downloads", "Max. concurrent downloads"], ["Automatische Wiederholungen", "Automatic retries"],
|
||||
["Zielordner für heruntergeladene Dateien.", "Destination folder for downloaded files."], ["Fehlende Arbeitsordner beim Start anlegen", "Create missing work folders on startup"], ["Erstellt den Download-Ordner sowie bei aktiver Funktion den Entpack- und Videosammelordner neu. Vorhandene Ordner und Inhalte bleiben unverändert.", "Creates the download folder and, when enabled, the extraction and video library folders. Existing folders and contents remain unchanged."],
|
||||
["Zielordner für heruntergeladene Dateien.", "Destination folder for downloaded files."], ["Fehlende Arbeitsordner beim Start anlegen", "Create missing work folders on startup"], ["Erstellt fehlende Download-, Entpack- und Videosammelordner sofort beim Speichern sowie bei jedem Programmstart. Optionale Ordner werden nur bei aktiver Funktion angelegt; vorhandene Inhalte bleiben unverändert.", "Creates missing download, extraction, and video library folders immediately when settings are saved and on every application start. Optional folders are created only when their feature is enabled; existing contents remain unchanged."],
|
||||
["Beim Start automatisch fortsetzen", "Resume automatically on startup"], ["Zwischenablage überwachen", "Monitor clipboard"], ["Verlauf speichern", "Save history"], ["Nur aktuelle Session", "Current session only"], ["Nur letzte 100 Einträge", "Last 100 entries only"], ["Nur letzte 250 Einträge", "Last 250 entries only"], ["Dauerhaft", "Permanent"],
|
||||
["Maximale Verlauf-Einträge", "Maximum history entries"], ["Einträge löschen älter als (Tage)", "Delete entries older than (days)"], ["Neue Pakete eingeklappt zeigen", "Show new packages collapsed"], ["Animationen", "Animations"],
|
||||
["In den Infobereich minimieren", "Minimize to tray"], ["Vor dem Löschen nachfragen", "Confirm before deleting"], ["Download-Liste mitsichern", "Include download list in backup"],
|
||||
|
||||
@@ -588,7 +588,7 @@ export function buildSettingsFormViewModel({
|
||||
kind: "switch",
|
||||
label: "Fehlende Arbeitsordner beim Start anlegen",
|
||||
value: settings.createWorkDirectoriesOnStartup,
|
||||
help: "Erstellt den Download-Ordner sowie bei aktiver Funktion den Entpack- und Videosammelordner neu. Vorhandene Ordner und Inhalte bleiben unverändert."
|
||||
help: "Erstellt fehlende Download-, Entpack- und Videosammelordner sofort beim Speichern sowie bei jedem Programmstart. Optionale Ordner werden nur bei aktiver Funktion angelegt; vorhandene Inhalte bleiben unverändert."
|
||||
},
|
||||
{ id: "packageName", kind: "text", label: "Paketname (optional)", value: settings.packageName },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user