separate unlink file and dir

This commit is contained in:
Abhinav 2022-08-26 16:16:16 +05:30
parent 8c9a4136ac
commit dab960ea47
2 changed files with 9 additions and 12 deletions

View file

@ -84,17 +84,14 @@ export function registerWatcherFunctions(
await removeFile(filePath);
await addFile(await getElectronFile(filePath));
});
ipcRenderer.on(
'watch-unlink',
async (_, filePath: string, isDir?: boolean) => {
filePath = filePath.split(path.sep).join(path.posix.sep);
if (isDir) {
await removeFolder(filePath);
} else {
await removeFile(filePath);
}
}
);
ipcRenderer.on('watch-unlink', async (_, filePath: string) => {
filePath = filePath.split(path.sep).join(path.posix.sep);
await removeFile(filePath);
});
ipcRenderer.on('watch-unlink-dir', async (_, folderPath: string) => {
folderPath = folderPath.split(path.sep).join(path.posix.sep);
await removeFolder(folderPath);
});
}
export { getWatchMappings } from '../services/watch';

View file

@ -23,7 +23,7 @@ export function initWatcher(mainWindow: BrowserWindow) {
mainWindow.webContents.send('watch-unlink', path);
})
.on('unlinkDir', (path) => {
mainWindow.webContents.send('watch-unlink', path, true);
mainWindow.webContents.send('watch-unlink-dir', path);
})
.on('error', (error) => {
logError(error, 'error while watching files');