Skip to content

Commit

Permalink
FIX: Log Backups (#2150)
Browse files Browse the repository at this point in the history
Added default value if config hasn't been updated yet
  • Loading branch information
PatrickRL authored Dec 17, 2024
1 parent 2876801 commit 20e443b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions launcher/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ log.transports.file.archiveLogFn = async (file) => {
renameSync(file, `${backupPath}main-${Date.now()}.log`);

let backupLogs = [];
let backupAmount = 3;

const storedConfig = await storageService.readConfig();
if (storedConfig.logBackups) {
backupAmount = storedConfig.logBackups.value;
}

readdir(backupPath, (err, files) => {
files.forEach((file) => {
backupLogs.push(file);
});
if (backupLogs.length > storedConfig.logBackups.value) {
if (backupLogs.length > backupAmount) {
backupLogs.reverse();
for (let i = storedConfig.logBackups.value; i < backupLogs.length; i++) {
for (let i = backupAmount; i < backupLogs.length; i++) {
rmSync(backupPath + backupLogs[i], { force: true }, (err) => {
if (err) throw err;
});
Expand Down

0 comments on commit 20e443b

Please sign in to comment.