separate unlink file and dir
This commit is contained in:
parent
8c9a4136ac
commit
dab960ea47
|
@ -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';
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue