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
This commit is contained in:
Observer KRypt0n_ 2022-01-07 18:52:15 +02:00
parent 483d7bd99a
commit 3d3bb5cb40
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
11 changed files with 198 additions and 58 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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'
}
});
});

View file

@ -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);

View file

@ -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 @@
/>
<Checkbox
lang="settings.enhancements.items.purge_dxvk_logs.title"
tooltip="settings.enhancements.items.purge_dxvk_logs.tooltip"
prop="purge_dxvk_logs"
lang="settings.enhancements.items.purge_logs.game.title"
tooltip="settings.enhancements.items.purge_logs.game.tooltip"
prop="purge_logs.game"
/>
<SelectionBox
lang="settings.enhancements.items.purge_logs.launcher.title"
tooltip="settings.enhancements.items.purge_logs.launcher.tooltip"
prop="purge_logs.launcher"
items={purgeLauncherLogs}
/>
</div>

View file

@ -184,8 +184,8 @@ export default (launcher: Launcher): Promise<void> => {
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);