From cf8a19575f5e2101cc7197ecd6176dbce317019e Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Mon, 28 Apr 2025 10:36:16 -0400 Subject: [PATCH] feature/IO-3205-Paint-Scale-Integrations: Checkpoint --- src/main/ipc/ipcMainConfig.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/ipc/ipcMainConfig.ts b/src/main/ipc/ipcMainConfig.ts index 830b5cd..4c5ad63 100644 --- a/src/main/ipc/ipcMainConfig.ts +++ b/src/main/ipc/ipcMainConfig.ts @@ -141,6 +141,11 @@ const inputTypeHandlers: Record< // Check for files const files = await fs.readdir(config.path!); for (const file of files) { + // Only process XML files + if (!file.toLowerCase().endsWith(".xml")) { + continue; + } + const filePath = path.join(config.path!, file); const stats = await fs.stat(filePath); if (stats.isFile()) { @@ -404,7 +409,12 @@ const outputTypeHandlers: Record< // Save XML to file const xmlString = doc.end({ prettyPrint: true }); - const outputPath = path.join(config.path!, "PPGPaint.xml"); + const timestamp = new Date() + .toISOString() + .replace(/[-:]/g, "") + .replace("T", "") + .substring(0, 14); + const outputPath = path.join(config.path!, `PPGPaint_${timestamp}.xml`); await fs.writeFile(outputPath, xmlString); log.info(`Saved PPG output XML to ${outputPath}`); } catch (error) { @@ -562,9 +572,7 @@ ipcMain.on( ipcTypes.toMain.settings.paintScale.updateInputCron, (_event, configs: PaintScaleConfig[]) => { handlePaintScaleInputCron(configs).catch((error) => { - log.error( - `Error handling paint scale input cron for configs: ${error}`, - ); + log.error(`Error handling paint scale input cron for configs: ${error}`); }); }, ); @@ -572,10 +580,8 @@ ipcMain.on( ipcMain.on( ipcTypes.toMain.settings.paintScale.updateOutputCron, (_event, configs: PaintScaleConfig[]) => { - handlePaintScaleOutputCron(configs).catch(error => { - log.error( - `Error handling paint scale output cron for configs: ${error}`, - ); + handlePaintScaleOutputCron(configs).catch((error) => { + log.error(`Error handling paint scale output cron for configs: ${error}`); }); }, ); @@ -604,4 +610,4 @@ ipcMain.on(ipcTypes.toMain.updates.download, () => { }); }); -logIpcMessages(); \ No newline at end of file +logIpcMessages();