From 5414f9dacd6971f5b9e8ae96b489a16cd10e6e97 Mon Sep 17 00:00:00 2001 From: salman Date: Wed, 17 Jun 2026 16:52:19 +0200 Subject: [PATCH] Fix regressions --- TrimSPelec.js | 7 +++++++ TrimSPlib.js | 22 +++++++++++++++------- main.js | 7 ++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/TrimSPelec.js b/TrimSPelec.js index 388ce25..0e60de0 100644 --- a/TrimSPelec.js +++ b/TrimSPelec.js @@ -46,6 +46,10 @@ function getParallelJobCount() { function checkDir(directory) { // Check whether directory exists, if not create it + if (typeof directory !== 'string' || directory.length === 0) { + console.log('Invalid directory passed to checkDir:', directory); + return(0); + } if (!fs.existsSync(directory)) { // Folder does not exist try to create it fs.mkdir(directory,{recursive: true}, (err) => { @@ -83,6 +87,9 @@ function readAsciiFile(filename) { } function fileExists(filename) { + if (typeof filename !== 'string' || filename.length === 0) { + return 0; + } try { if (fs.existsSync(filename)) { return 1; diff --git a/TrimSPlib.js b/TrimSPlib.js index 7ddf7dc..b2cc718 100644 --- a/TrimSPlib.js +++ b/TrimSPlib.js @@ -3433,6 +3433,13 @@ function prep_cfg(toggle) { let valtmp = ""; All['trimPath']=document.getElementById("trimPath").value; + // Keep file output settings in the runtime state even though they are not + // part of the projectile block. The scan runner depends on both values. + All["fileNamePrefix"] = document.getElementById("fileNamePrefix").value; + All["workPath"] = document.getElementById("workPath").value; + // Thread count is a local GUI/runtime setting only. It must stay out of + // TrimSP.cfg, but the local parallel runner still needs to read it. + All["scanThreads"] = document.getElementById("scanThreads").value; // Prepare Layers section let LayersSec = "[Layers]\n"; @@ -3762,21 +3769,22 @@ async function startSequence() { } } - if (All["comboScan"]==1) { + if (All["comboScan"]=="SigEScan") { ScanName = "SigE"; ScanAttrib = "sigEnergy"; - } else if (All["comboScan"]==2) { + } else if (All["comboScan"]=="AngleScan") { ScanName = "Angle"; ScanAttrib = "valAngle"; - } else if (All["comboScan"]==3) { + } else if (All["comboScan"]=="SigAngleScan") { ScanName = "SigAngle"; ScanAttrib = "sigAngle"; - } else if (All["comboScan"]==4) { + } else if (All["comboScan"]=="NProjScan") { ScanName = "N"; ScanAttrib = "numberProj"; - } else if (All["comboScan"]==5) { - ScanName = "Ld"+All["scandL"]; - ScanAttrib = "L"+All["scandL"]+"d"; + } else if (All["comboScan"]=="dScan") { + // The GUI currently exposes the thickness scan only for layer 1. + ScanName = "Ld1"; + ScanAttrib = "L1d"; } } else { // For single run, array with single value of valEnergy diff --git a/main.js b/main.js index 4495230..197c38b 100644 --- a/main.js +++ b/main.js @@ -46,13 +46,13 @@ function parseStartupOptions(argv) { for (const candidate of candidates) { if (!matcher) { const nextPath = path.join(candidate, segment); - if (fs.existsSync(nextPath)) { + if (typeof nextPath === 'string' && fs.existsSync(nextPath)) { nextCandidates.push(nextPath); } continue; } - if (!fs.existsSync(candidate) || !fs.statSync(candidate).isDirectory()) { + if (typeof candidate !== 'string' || !fs.existsSync(candidate) || !fs.statSync(candidate).isDirectory()) { continue; } @@ -71,12 +71,13 @@ function parseStartupOptions(argv) { } candidates = candidates - .filter((candidate) => fs.existsSync(candidate) && fs.statSync(candidate).isFile()) + .filter((candidate) => typeof candidate === 'string' && fs.existsSync(candidate) && fs.statSync(candidate).isFile()) .sort(); } for (const candidate of candidates) { if ( + typeof candidate === 'string' && path.extname(candidate).toLowerCase() === '.cfg' && fs.existsSync(candidate) && fs.statSync(candidate).isFile() &&