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

@ -80,5 +80,6 @@ add_user 'audiobookshelf' '' 'audiobookshelf' 'audiobookshelf user-daemon' '/bin
mkdir -p '/var/log/audiobookshelf'
chown -R 'audiobookshelf:audiobookshelf' '/var/log/audiobookshelf'
chown -R 'audiobookshelf:audiobookshelf' '/usr/share/audiobookshelf'
start_service 'audiobookshelf'

View File

@ -14,7 +14,7 @@
"build-prep": "npm run build-client && npm run build-server",
"build-win": "npm run build-prep && pkg -t node12-win-x64 -o ./dist/win/audiobookshelf .",
"build-linuxarm": "npm run build-prep && pkg -t node12-linux-arm64 -o ./dist/linuxarm/audiobookshelf .",
"build-linux": "npm run build-prep && pkg -t node12-linux-x64 -o dist/linux/audiobookshelf . && cp dist/linux/audiobookshelf build/debian/usr/share/"
"build-linux": "npm run build-prep && pkg -t node12-linux-x64 -o dist/linux/audiobookshelf . && cp dist/linux/audiobookshelf build/debian/usr/share/audiobookshelf/ && chmod -R 775 build/debian/"
},
"bin": "prod.js",
"pkg": {

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') {

View File

@ -65,12 +65,13 @@ class StreamManager {
if (!dirs || !dirs.length) return true
await Promise.all(dirs.map(async (dirname) => {
if (dirname !== 'streams' && dirname !== 'books') {
if (dirname !== 'streams' && dirname !== 'books' && dirname !== 'downloads') {
var fullPath = Path.join(this.MetadataPath, dirname)
Logger.warn(`Removing OLD Orphan Stream ${dirname}`)
return fs.remove(fullPath)
}
}))
return true
} catch (error) {
Logger.debug('No old orphan streams', error)