(req: Request, res: Response)
| 333 | } |
| 334 | |
| 335 | export async function ApiUpdateStableDiffusionConfig(req: Request, res: Response) { |
| 336 | try { |
| 337 | const { data } = req.body; |
| 338 | const stableDiffusionPath = (data.stableDiffusionDir || "").trim(); |
| 339 | |
| 340 | if (stableDiffusionPath === "") { |
| 341 | throw new Error("SD WebUI path is empty") |
| 342 | } |
| 343 | |
| 344 | if (stableDiffusionPath !== "") { |
| 345 | if (!fsExtra.existsSync(path.resolve(stableDiffusionPath, "webui.py"))) { |
| 346 | throw new Error("Can't find webui.py in stable diffusion path, please check if it's a valid diffusion path"); |
| 347 | } |
| 348 | |
| 349 | if (!fsExtra.existsSync(path.resolve(stableDiffusionPath, "models"))) { |
| 350 | throw new Error("Can't find models in stable diffusion path, please check if it's a valid diffusion path"); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | const comfyUIDir = getComfyUIDir(); |
| 355 | const setupString = JSON.stringify({ |
| 356 | comfyUIDir, |
| 357 | stableDiffusionDir: stableDiffusionPath |
| 358 | }); |
| 359 | |
| 360 | appConfigManager.set(CONFIG_KEYS.appSetupConfig, setupString); |
| 361 | createOrUpdateExtraConfigFileFromStableDiffusion(stableDiffusionPath) |
| 362 | res.send({ |
| 363 | success: true, |
| 364 | }); |
| 365 | } catch (err: any) { |
| 366 | logger.error(err.message + ":" + err.stack); |
| 367 | res.send({ |
| 368 | success: false, |
| 369 | error: err.message |
| 370 | }); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | export async function ApiRestartComfyUI(req: Request, res: Response) { |
| 375 | try { |
nothing calls this directly
no test coverage detected