diff --git a/server/DownloadManager.js b/server/DownloadManager.js index bbfe1708..45a0213d 100644 --- a/server/DownloadManager.js +++ b/server/DownloadManager.js @@ -5,16 +5,18 @@ const archiver = require('archiver') const workerThreads = require('worker_threads') const Logger = require('./Logger') const Download = require('./objects/Download') +const filePerms = require('./utils/filePerms') const { getId } = require('./utils/index') const { writeConcatFile, writeMetadataFile } = require('./utils/ffmpegHelpers') const { getFileSize } = require('./utils/fileUtils') const TAG = 'DownloadManager' class DownloadManager { - constructor(db, MetadataPath, AudiobookPath, emitter) { + constructor(db, MetadataPath, AudiobookPath, Uid, Gid) { + this.Uid = Uid + this.Gid = Gid this.db = db this.MetadataPath = MetadataPath this.AudiobookPath = AudiobookPath - this.emitter = emitter this.downloadDirPath = Path.join(this.MetadataPath, 'downloads') @@ -343,6 +345,9 @@ class DownloadManager { return } + // Set file permissions and ownership + await filePerms(download.fullPath, 0o774, this.Uid, this.Gid) + var filesize = await getFileSize(download.fullPath) download.setComplete(filesize) if (download.socket) { diff --git a/server/Server.js b/server/Server.js index 21ec5504..10eeae8a 100644 --- a/server/Server.js +++ b/server/Server.js @@ -54,7 +54,7 @@ class Server { this.streamManager = new StreamManager(this.db, this.MetadataPath, this.emitter.bind(this), this.clientEmitter.bind(this)) this.rssFeeds = new RssFeeds(this.Port, this.db) - this.downloadManager = new DownloadManager(this.db, this.MetadataPath, this.AudiobookPath, this.emitter.bind(this)) + this.downloadManager = new DownloadManager(this.db, this.MetadataPath, this.AudiobookPath, this.Uid, this.Gid) this.apiController = new ApiController(this.MetadataPath, this.db, this.auth, this.streamManager, this.rssFeeds, this.downloadManager, this.coverController, this.backupManager, this.watcher, this.cacheManager, this.emitter.bind(this), this.clientEmitter.bind(this)) this.hlsController = new HlsController(this.db, this.auth, this.streamManager, this.emitter.bind(this), this.streamManager.StreamsPath)