mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat] just set the deleteLogFolders than appending the new list
This commit is contained in:
+3
-5
@@ -224,15 +224,13 @@ function initLogger(){
|
||||
|
||||
// Keep only the past week (7 days) of logs
|
||||
function deleteOldLogs(): void {
|
||||
const deleteLogFolders: Dirent[] = [];
|
||||
let deleteLogFolders: Dirent[] = [];
|
||||
try {
|
||||
const filterDate = convertDateToDateString(
|
||||
new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) // 7 days
|
||||
);
|
||||
deleteLogFolders.push.apply([],
|
||||
readdirSync(app.getPath("logs"), { withFileTypes: true })
|
||||
.filter(folder => folder.isDirectory() && folder.name <= filterDate)
|
||||
);
|
||||
deleteLogFolders = readdirSync(app.getPath("logs"), { withFileTypes: true })
|
||||
.filter(folder => folder.isDirectory() && folder.name <= filterDate);
|
||||
} catch (error) {
|
||||
log.error("Error while deleting old logs:", error);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user