Skip to content

Commit

Permalink
fix(tts): fix tts config filepath issue
Browse files Browse the repository at this point in the history
fixes #174
  • Loading branch information
marisademeglio committed Dec 5, 2023
1 parent 315cbf9 commit 2c9aab1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 20 additions & 6 deletions src/main/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
})
}

Expand Down
6 changes: 5 additions & 1 deletion src/renderer/components/ScriptForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ 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(
settings.ttsConfig.xmlFilepath,
ttsConfigOpt,
inputs
)
} else if (!ttsConfigExists) {
App.log(`File does not exist ${settings.ttsConfig.xmlFilepath}`)
}

App.store.dispatch(
Expand Down

0 comments on commit 2c9aab1

Please sign in to comment.