Skip to content

Commit 20e443b

Browse files
authored
FIX: Log Backups (#2150)
Added default value if config hasn't been updated yet
1 parent 2876801 commit 20e443b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

launcher/src/background.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,20 @@ log.transports.file.archiveLogFn = async (file) => {
5050
renameSync(file, `${backupPath}main-${Date.now()}.log`);
5151

5252
let backupLogs = [];
53+
let backupAmount = 3;
5354

5455
const storedConfig = await storageService.readConfig();
56+
if (storedConfig.logBackups) {
57+
backupAmount = storedConfig.logBackups.value;
58+
}
5559

5660
readdir(backupPath, (err, files) => {
5761
files.forEach((file) => {
5862
backupLogs.push(file);
5963
});
60-
if (backupLogs.length > storedConfig.logBackups.value) {
64+
if (backupLogs.length > backupAmount) {
6165
backupLogs.reverse();
62-
for (let i = storedConfig.logBackups.value; i < backupLogs.length; i++) {
66+
for (let i = backupAmount; i < backupLogs.length; i++) {
6367
rmSync(backupPath + backupLogs[i], { force: true }, (err) => {
6468
if (err) throw err;
6569
});

0 commit comments

Comments
 (0)