diff --git a/build/debian/DEBIAN/postinst b/build/debian/DEBIAN/postinst index 92af782d..dd6394b5 100644 --- a/build/debian/DEBIAN/postinst +++ b/build/debian/DEBIAN/postinst @@ -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' diff --git a/package.json b/package.json index 56f2bd17..13458852 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/server/DownloadManager.js b/server/DownloadManager.js index ec6d0d76..563deed1 100644 --- a/server/DownloadManager.js +++ b/server/DownloadManager.js @@ -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') { diff --git a/server/StreamManager.js b/server/StreamManager.js index a0108908..5ec244a5 100644 --- a/server/StreamManager.js +++ b/server/StreamManager.js @@ -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)