Fix check old streams in metadata, download manager worker thread path

This commit is contained in:
Mark Cooper 2021-09-25 10:35:33 -05:00
parent 69cd6aa4d0
commit 03f39d71e3
4 changed files with 21 additions and 4 deletions

View file

@ -7,7 +7,7 @@ const Logger = require('./Logger')
const Download = require('./objects/Download')
const { writeConcatFile, writeMetadataFile } = require('./utils/ffmpegHelpers')
const { getFileSize } = require('./utils/fileUtils')
const TAG = 'DownloadManager'
class DownloadManager {
constructor(db, MetadataPath, AudiobookPath, emitter) {
this.db = db
@ -260,7 +260,22 @@ class DownloadManager {
output: download.fullPath,
}
var worker = new workerThreads.Worker('./server/utils/downloadWorker.js', { workerData })
var worker = null
try {
var workerPath = Path.join(global.appRoot, 'server/utils/downloadWorker.js')
Logger.info(`[${TAG}] Worker Path: ${workerPath}`)
worker = new workerThreads.Worker(workerPath, { workerData })
} catch (error) {
Logger.error(`[${TAG}] Start worker thread failed`, error)
if (download.socket) {
var downloadJson = download.toJSON()
download.socket.emit('download_failed', downloadJson)
}
this.removeDownload(download)
return
}
worker.on('message', (message) => {
if (message != null && typeof message === 'object') {
if (message.type === 'RESULT') {