Resolve portable run paths for Electron metadata

This commit is contained in:
salman committed 2026-11-19 13:37:05 +01:00
1 parent aa670d5874
commit 716b0efbc0
2 files changed
+27

No files matched your search

+23
View File
@@ -397,6 +397,29 @@ window.MusRFlowPlatform.resolveDataFile = function(runName) {
let resolved = resolveLocalRunData(file.run, file.year, file.instrument);
if (resolved && resolved.runName === runName) return resolved.filePath;
}
// Portable RUN directives omit the data-file extension and rely on
// musrfit_startup.xml search paths. dump_header does not perform that same
// lookup, so resolve the token to an existing file before launching it.
// portableRunResolver enforces a relative, traversal-free path beneath the
// configured root; only known muSR data extensions are considered.
let startup = typeof portableRunNamingStartup !== "undefined"
? portableRunNamingStartup : null;
let roots = startup && Array.isArray(startup.dataPaths)
? startup.dataPaths : [];
let candidates = [String(runName || "")];
if (!/\.(?:root|bin|mdu|msr|nxs)$/i.test(candidates[0])) {
candidates = candidates.concat([".root", ".bin", ".mdu", ".msr", ".nxs"].map(
function(extension) { return candidates[0] + extension; }
));
}
for (let root of roots) {
for (let candidate of candidates) {
if (portableRunResolver(candidate, root)) {
return nodePath.join(root, candidate);
}
}
}
return '';
};
+4
View File
@@ -86,6 +86,10 @@ function testPortableEnabledViaConfiguredXml() {
lib.runFileNameAuto(514, "2026", "LEM", "/psi.ch/data/"),
"RUN d2026/tdc/lem26_his_0514 MUE4 PSI MUSR-ROOT"
);
assert.strictEqual(
lib.window.MusRFlowPlatform.resolveDataFile("d2026/tdc/lem26_his_0514"),
portableFile
);
// The indicator is null-safe in a document without the status element.
assert.strictEqual(lib.updateStartupNamingSourceIndicator(), undefined);
}