Fix:Downloader sets file permission and owner on files #286

This commit is contained in:
advplyr 2022-02-03 18:08:39 -06:00
parent 405d333d60
commit 590dbe3991
2 changed files with 8 additions and 3 deletions

View File

@ -5,16 +5,18 @@ const archiver = require('archiver')
const workerThreads = require('worker_threads') const workerThreads = require('worker_threads')
const Logger = require('./Logger') const Logger = require('./Logger')
const Download = require('./objects/Download') const Download = require('./objects/Download')
const filePerms = require('./utils/filePerms')
const { getId } = require('./utils/index') const { getId } = require('./utils/index')
const { writeConcatFile, writeMetadataFile } = require('./utils/ffmpegHelpers') const { writeConcatFile, writeMetadataFile } = require('./utils/ffmpegHelpers')
const { getFileSize } = require('./utils/fileUtils') const { getFileSize } = require('./utils/fileUtils')
const TAG = 'DownloadManager' const TAG = 'DownloadManager'
class DownloadManager { class DownloadManager {
constructor(db, MetadataPath, AudiobookPath, emitter) { constructor(db, MetadataPath, AudiobookPath, Uid, Gid) {
this.Uid = Uid
this.Gid = Gid
this.db = db this.db = db
this.MetadataPath = MetadataPath this.MetadataPath = MetadataPath
this.AudiobookPath = AudiobookPath this.AudiobookPath = AudiobookPath
this.emitter = emitter
this.downloadDirPath = Path.join(this.MetadataPath, 'downloads') this.downloadDirPath = Path.join(this.MetadataPath, 'downloads')
@ -343,6 +345,9 @@ class DownloadManager {
return return
} }
// Set file permissions and ownership
await filePerms(download.fullPath, 0o774, this.Uid, this.Gid)
var filesize = await getFileSize(download.fullPath) var filesize = await getFileSize(download.fullPath)
download.setComplete(filesize) download.setComplete(filesize)
if (download.socket) { if (download.socket) {

View File

@ -54,7 +54,7 @@ class Server {
this.streamManager = new StreamManager(this.db, this.MetadataPath, this.emitter.bind(this), this.clientEmitter.bind(this)) 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.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.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) this.hlsController = new HlsController(this.db, this.auth, this.streamManager, this.emitter.bind(this), this.streamManager.StreamsPath)