From 3d3bb5cb40d7ed553463d1ffaee23fef1a1fae23 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 7 Jan 2022 18:52:15 +0200 Subject: [PATCH] Reworked log files deletion system - removed `purge_dxvk_logs` config - added `purge_logs.game` and `purge_logs.launcher` configs - now launcher can delete its own old log files --- public/locales/de-de.yaml | 24 ++++++++++++++---- public/locales/en-us.yaml | 24 ++++++++++++++---- public/locales/es-es.yaml | 24 ++++++++++++++---- public/locales/fr-fr.yaml | 24 ++++++++++++++---- public/locales/it-it.yaml | 20 ++++++++++++--- public/locales/ru-ru.yaml | 22 ++++++++++++++--- public/locales/vi-vn.yaml | 24 ++++++++++++++---- src/defaultSettings.ts | 22 ++++++++++++++--- src/index.svelte | 42 +++++++++++++++++++------------- src/settings.svelte | 26 +++++++++++++++++--- src/ts/launcher/states/Launch.ts | 4 +-- 11 files changed, 198 insertions(+), 58 deletions(-) diff --git a/public/locales/de-de.yaml b/public/locales/de-de.yaml index 20909ae..c914239 100644 --- a/public/locales/de-de.yaml +++ b/public/locales/de-de.yaml @@ -81,11 +81,25 @@ settings: title: Entsperre FPS tooltip: Diese option entsperrt/entfernt die 60 FPS limiterung - # Delete DXVK logs - purge_dxvk_logs: - title: DXVK logs löschen - tooltip: When diese option angeschaltet ist löscht - der Launcher automatisch alle DXVK logs + # Delete logs + purge_logs: + # Game logs (DXVK) + game: + title: DXVK logs löschen + tooltip: When diese option angeschaltet ist löscht + der Launcher automatisch alle DXVK logs + + # Launcher logs + launcher: + title: Launcher logs löschen + tooltip: Launcher logs werden nach diese angegebenen Zeit gelöscht + items: + 1d: 1 Tag + 3d: 3 Tage + 5d: 5 Tage + 7d: 1 Woche + 14d: 2 Wochen + never: Niemals # Runners runners: diff --git a/public/locales/en-us.yaml b/public/locales/en-us.yaml index 3f0be9e..ea3cc03 100644 --- a/public/locales/en-us.yaml +++ b/public/locales/en-us.yaml @@ -81,11 +81,25 @@ settings: title: Unlock FPS tooltip: This option will unlock maximum of the 60 fps limitation - # Delete DXVK logs - purge_dxvk_logs: - title: Delete DXVK logs - tooltip: With this option enabled your launcher will automatically - delete DXVK log files + # Delete logs + purge_logs: + # Game logs (DXVK) + game: + title: Delete DXVK logs + tooltip: With this option enabled your launcher will automatically + delete DXVK log files + + # Launcher logs + launcher: + title: Delete launcher logs + tooltip: Amount of time after which launcher will delete its old log files + items: + 1d: 1 day + 3d: 3 days + 5d: 5 days + 7d: 1 week + 14d: 2 weeks + never: Never # Runners runners: diff --git a/public/locales/es-es.yaml b/public/locales/es-es.yaml index df3fd1d..3b93b75 100644 --- a/public/locales/es-es.yaml +++ b/public/locales/es-es.yaml @@ -81,11 +81,25 @@ settings: title: Unlock FPS tooltip: This option will unlock maximum of the 60 fps limitation - # Delete DXVK logs - purge_dxvk_logs: - title: Delete DXVK logs - tooltip: With this option enabled your launcher will automatically - delete DXVK log files + # Delete logs + purge_logs: + # Game logs (DXVK) + game: + title: Delete DXVK logs + tooltip: With this option enabled your launcher will automatically + delete DXVK log files + + # Launcher logs + launcher: + title: Delete launcher logs + tooltip: Amount of time after which launcher will delete its old log files + items: + 1d: 1 day + 3d: 3 days + 5d: 5 days + 7d: 1 week + 14d: 2 weeks + never: Never # Runners runners: diff --git a/public/locales/fr-fr.yaml b/public/locales/fr-fr.yaml index dabad39..b4650d1 100644 --- a/public/locales/fr-fr.yaml +++ b/public/locales/fr-fr.yaml @@ -84,11 +84,25 @@ settings: tooltip: Cette option permet de débloque le nombre d'image par secondes (IPS) au-delà de 60 - # Delete DXVK logs - purge_dxvk_logs: - title: Supprimer automatiquement les logs de DXVK - tooltip: Cette option supprime automatiquement les - fichiers logs de DXVK + # Delete logs + purge_logs: + # Game logs (DXVK) + game: + title: Supprimer automatiquement les logs de DXVK + tooltip: Cette option supprime automatiquement les + fichiers logs de DXVK + + # Launcher logs + launcher: + title: Suppression des fichiers logs + tooltip: Amount of time after which launcher will delete its old log files + items: + 1d: Tous les jours + 3d: Tous les 3 jours + 5d: Tous les 5 jours + 7d: Toutes les semaines + 14d: Toutes les 2 semaines + never: Jamais # Runners runners: diff --git a/public/locales/it-it.yaml b/public/locales/it-it.yaml index 0eb69b3..960d141 100644 --- a/public/locales/it-it.yaml +++ b/public/locales/it-it.yaml @@ -81,9 +81,23 @@ settings: tooltip: Questa opzione rimuoverà la limitazione di 60 FPS in gioco # Delete DXVK logs - purge_dxvk_logs: - title: Cancella i log DXVK - tooltip: Con questa opzione attiva, il launcher cancellerà automaticamente i file di log DXVK + purge_logs: + # Game logs (DXVK) + game: + title: Cancella i log DXVK + tooltip: Con questa opzione attiva, il launcher cancellerà automaticamente i file di log DXVK + + # Launcher logs + launcher: + title: Delete launcher logs + tooltip: Amount of time after which launcher will delete its old log files + items: + 1d: 1 day + 3d: 3 days + 5d: 5 days + 7d: 1 week + 14d: 2 weeks + never: Never # Runners runners: diff --git a/public/locales/ru-ru.yaml b/public/locales/ru-ru.yaml index 2a02045..ccae317 100644 --- a/public/locales/ru-ru.yaml +++ b/public/locales/ru-ru.yaml @@ -81,10 +81,24 @@ settings: title: Разблокировать FPS tooltip: Эта опция позволит разблокировать лимит на отрисовку не более чем 60 кадров в секунду - # Удалять логи DXVK - purge_dxvk_logs: - title: Удалять логи DXVK - tooltip: Если включено, лаунчер будет автоматически удалять логи DXVK + # Удалять логи + purge_logs: + # Игры (DXVK) + game: + title: Удалять логи DXVK + tooltip: Если включено, лаунчер будет автоматически удалять логи DXVK + + # Лаунчера + launcher: + title: Удалять логи лаунчера + tooltip: Время, после которого удалять старые логи лаунчера + items: + 1d: 1 день + 3d: 3 дня + 5d: 5 дней + 7d: 1 неделя + 14d: 2 недели + never: Никогда # Версии Wine runners: diff --git a/public/locales/vi-vn.yaml b/public/locales/vi-vn.yaml index df3fd1d..3b93b75 100644 --- a/public/locales/vi-vn.yaml +++ b/public/locales/vi-vn.yaml @@ -81,11 +81,25 @@ settings: title: Unlock FPS tooltip: This option will unlock maximum of the 60 fps limitation - # Delete DXVK logs - purge_dxvk_logs: - title: Delete DXVK logs - tooltip: With this option enabled your launcher will automatically - delete DXVK log files + # Delete logs + purge_logs: + # Game logs (DXVK) + game: + title: Delete DXVK logs + tooltip: With this option enabled your launcher will automatically + delete DXVK log files + + # Launcher logs + launcher: + title: Delete launcher logs + tooltip: Amount of time after which launcher will delete its old log files + items: + 1d: 1 day + 3d: 3 days + 5d: 5 days + 7d: 1 week + 14d: 2 weeks + never: Never # Runners runners: diff --git a/src/defaultSettings.ts b/src/defaultSettings.ts index b022dea..e331f7d 100644 --- a/src/defaultSettings.ts +++ b/src/defaultSettings.ts @@ -133,10 +133,24 @@ promisify(async () => { fps_unlocker: false, /** - * If the launcher should automatically delete DXVK log files - * - * @default true + * If the launcher should automatically delete log files */ - purge_dxvk_logs: true + purge_logs: { + /** + * Should launcher delete some game logs (DXVK .log and .dmp files) + * + * @default true + */ + game: true, + + /** + * Period of time launcher should delete its logs + * + * Can be in "*d" format, where * is amount of days (e.g. 5d = 5 days), or "never" to never delete logs + * + * @default "5d" + */ + launcher: '5d' + } }); }); diff --git a/src/index.svelte b/src/index.svelte index 8ef419b..0595859 100644 --- a/src/index.svelte +++ b/src/index.svelte @@ -17,6 +17,7 @@ import Downloader from './ts/core/Downloader'; import IPC from './ts/core/IPC'; import Process from './ts/neutralino/Process'; + import Configs from './ts/Configs'; import Gear from './assets/images/gear.png'; import GearActive from './assets/images/gear-active.png'; @@ -44,30 +45,37 @@ }); }); - Neutralino.events.on('windowClose', () => { + Neutralino.events.on('windowClose', async () => { Downloader.closeStreams(true); Archive.closeStreams(true); - constants.paths.tempDir.then(async (tempDir) => { - // Remove IPC file - await IPC.purge(); + const tempDir = await constants.paths.tempDir; + const launcherDir = await constants.paths.launcherDir; - // Turn off Discord RPC - if (launcher.rpc) - await launcher.rpc.stop(true); + // Remove IPC file + await IPC.purge(); - // Remove .tmp files from the temp folder - await Neutralino.os.execCommand(`find "${Process.addSlashes(tempDir)}" -maxdepth 1 -type f -name "*.tmp" -delete`); + // Turn off Discord RPC + if (launcher.rpc) + await launcher.rpc.stop(true); - // Save logs - const log = Debug.get().join("\r\n"); + // Remove .tmp files from the temp folder + await Neutralino.os.execCommand(`find "${Process.addSlashes(tempDir)}" -maxdepth 1 -type f -name "*.tmp" -delete`); - if (log != '') - await Neutralino.filesystem.writeFile(`${await constants.paths.launcherDir}/logs/${Debug.startedAt.getDate()}-${Debug.startedAt.getMonth() + 1}-${Debug.startedAt.getFullYear()}-${Debug.startedAt.getHours()}-${Debug.startedAt.getMinutes()}-${Debug.startedAt.getSeconds()}.log`, log); + // Remove old launcher's log files + const purge_logs = await Configs.get('purge_logs.launcher') as string|null; - // And close the launcher when they was saved - Neutralino.app.exit(); - }); + if (purge_logs !== null && purge_logs[purge_logs.length - 1] == 'd') + await Neutralino.os.execCommand(`find "${Process.addSlashes(launcherDir)}/logs" -maxdepth 1 -mtime +${purge_logs.substring(0, purge_logs.length - 1)} -delete`); + + // Save logs + const log = Debug.get().join('\r\n'); + + if (log != '') + await Neutralino.filesystem.writeFile(`${launcherDir}/logs/${Debug.startedAt.getDate()}-${Debug.startedAt.getMonth() + 1}-${Debug.startedAt.getFullYear()}-${Debug.startedAt.getHours()}-${Debug.startedAt.getMinutes()}-${Debug.startedAt.getSeconds()}.log`, log); + + // And close the launcher when they was saved + Neutralino.app.exit(); }); // Save logs @@ -79,7 +87,7 @@ logSavingStarted = true; setTimeout(async () => { - const log = `=== Log can be incomplete ===\r\n\r\n${Debug.get().join("\r\n")}`; + const log = `=== Log can be incomplete ===\r\n\r\n${Debug.get().join('\r\n')}`; if (log != '') await Neutralino.filesystem.writeFile(`${await constants.paths.launcherDir}/logs/${Debug.startedAt.getDate()}-${Debug.startedAt.getMonth() + 1}-${Debug.startedAt.getFullYear()}-${Debug.startedAt.getHours()}-${Debug.startedAt.getMinutes()}-${Debug.startedAt.getSeconds()}.log`, log); diff --git a/src/settings.svelte b/src/settings.svelte index 5d5beea..1126b51 100644 --- a/src/settings.svelte +++ b/src/settings.svelte @@ -64,6 +64,19 @@ 'mangohud': 'settings.enhancements.items.hud.items.mangohud' }; + /** + * Delete launcher logs options + */ + + const purgeLauncherLogs = { + '1d': 'settings.enhancements.items.purge_logs.launcher.items.1d', + '3d': 'settings.enhancements.items.purge_logs.launcher.items.3d', + '5d': 'settings.enhancements.items.purge_logs.launcher.items.5d', + '7d': 'settings.enhancements.items.purge_logs.launcher.items.7d', + '14d': 'settings.enhancements.items.purge_logs.launcher.items.14d', + 'never': 'settings.enhancements.items.purge_logs.launcher.items.never' + }; + /** * Menu items */ @@ -248,9 +261,16 @@ /> + + diff --git a/src/ts/launcher/states/Launch.ts b/src/ts/launcher/states/Launch.ts index 2db5173..6040c5c 100644 --- a/src/ts/launcher/states/Launch.ts +++ b/src/ts/launcher/states/Launch.ts @@ -184,8 +184,8 @@ export default (launcher: Launcher): Promise => { launcher.updateDiscordRPC('in-launcher'); launcher.tray.hide(); - // Purge DXVK logs - Configs.get('purge_dxvk_logs').then(async (purge_logs) => { + // Purge game logs + Configs.get('purge_logs.game').then(async (purge_logs) => { if (purge_logs) { const gameDir = Process.addSlashes(await constants.paths.gameDir);