Skip to content

Commit

Permalink
temp cleaner added
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Aug 16, 2023
1 parent e47f0d6 commit ebf7491
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions electron/fs/deleteAllFilesInDir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import fs from 'fs/promises';
import path from 'path';

export default async function deleteAllFilesInDir(dirPath) {
try {
const files = await fs.readdir(dirPath);

const deleteFilePromises = files.map(file =>
fs.unlink(path.join(dirPath, file)),
);

await Promise.all(deleteFilePromises);
} catch (err) {
console.log(err);
}
};
4 changes: 4 additions & 0 deletions electron/main/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import fs from 'fs';
import path from 'path';
import { app, Notification } from 'electron';

import deleteAllFilesInDir from '../../fs/deleteAllFilesInDir';
import { objType } from '../../../src/util/tools';

// Validate Folders
const tempFolder = path.join(app.getPath('temp'), './pony-house-matrix');
if (!fs.existsSync(tempFolder)) {
fs.mkdirSync(tempFolder);
Expand All @@ -14,6 +16,8 @@ if (!fs.existsSync(tempFolderNoti)) {
fs.mkdirSync(tempFolderNoti);
}

deleteAllFilesInDir(tempFolderNoti);

// Module
const notifications = {};
export default function startNotifications(ipcMain) {
Expand Down

0 comments on commit ebf7491

Please sign in to comment.