From 2c9aab132a19ca0b5efc95698545b3c9315633b8 Mon Sep 17 00:00:00 2001 From: Marisa DeMeglio Date: Tue, 5 Dec 2023 13:35:59 -0800 Subject: [PATCH] fix(tts): fix tts config filepath issue fixes #174 --- package.json | 2 +- src/main/fileSystem.ts | 26 +++++++++++++++----- src/renderer/components/ScriptForm/index.tsx | 6 ++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index e75c27e2..05bd98da 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "displayName": "DAISY Pipeline (2023)", "name": "pipeline-ui", "description": "User interface for the DAISY Pipeline", - "version": "1.2.7-RC2", + "version": "1.2.7-RC3", "main": "./node_modules/.dev-temp-build/main.js", "devTempBuildFolder": "./node_modules/.dev-temp-build", "devServer": "http://localhost:4927", diff --git a/src/main/fileSystem.ts b/src/main/fileSystem.ts index 0b5a2673..413a90e8 100644 --- a/src/main/fileSystem.ts +++ b/src/main/fileSystem.ts @@ -6,14 +6,28 @@ import { IPC_EVENT_pathExists, IPC_EVENT_sniffEncoding, } from '../shared/main-renderer-events' +import { PLATFORM } from 'shared/constants' -async function pathExists(path) { - await fs.access(path, (err) => { - if (err) { - return false - } else { - return true +function pathExists(path) { + if (path.length == 0) return false + + let path_ = decodeURI(path).replace('file://', '') + // make sure the path is formatted like a path + if (PLATFORM.IS_WINDOWS) { + if (path_[0] == '/') { + path_ = path_.slice(1) + path_ = path_.replaceAll('/', '\\') } + } + + return new Promise((resolve, reject) => { + fs.access(path_, (err) => { + if (err) { + resolve(false) + } else { + resolve(true) + } + }) }) } diff --git a/src/renderer/components/ScriptForm/index.tsx b/src/renderer/components/ScriptForm/index.tsx index ef559771..3608ead1 100644 --- a/src/renderer/components/ScriptForm/index.tsx +++ b/src/renderer/components/ScriptForm/index.tsx @@ -71,7 +71,9 @@ export function ScriptForm({ job, script }: { job: Job; script: Script }) { let ttsConfigOpt = optional.find((o) => o.mediaType.includes('application/vnd.pipeline.tts-config+xml') ) - let ttsConfigExists = await App.pathExists(settings.ttsConfig.xmlFilepath) + let ttsConfigExists = await App.pathExists( + settings.ttsConfig.xmlFilepath + ) let inputs = [...job.jobRequest.inputs] if (ttsConfigOpt && ttsConfigExists) { inputs = updateArrayValue( @@ -79,6 +81,8 @@ export function ScriptForm({ job, script }: { job: Job; script: Script }) { ttsConfigOpt, inputs ) + } else if (!ttsConfigExists) { + App.log(`File does not exist ${settings.ttsConfig.xmlFilepath}`) } App.store.dispatch(