diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.ts index 9d99df1..6ad77c4 100644 --- a/src/main/ipc/index.ts +++ b/src/main/ipc/index.ts @@ -426,6 +426,16 @@ export function registerIpcHandlers(): void { return result }) ipcMain.handle('projects:update', async (_event, project) => { + // Clean up old config file if host changed + const projects = projectService.getProjects() + const oldProject = projects.find(p => p.id === project.id) + if (oldProject && oldProject.host !== project.host) { + const oldConfigPath = path.join(configService.getBasePath(), 'generated_configs', 'projects', `${oldProject.host}.conf`) + if (fs.existsSync(oldConfigPath)) { + try { fs.unlinkSync(oldConfigPath) } catch (e) { console.error('Error deleting old config:', e) } + } + } + const result = projectService.updateProject(project) // Trigger Nginx restart await restartNginx()