Fix: set downloaded/uploaded cover owner and permissions and if creating intitial config/metadata directories at startup then set owner of those #394

This commit is contained in:
advplyr 2022-04-24 19:12:00 -05:00
parent e253939c1e
commit dcd4f69383
3 changed files with 34 additions and 3 deletions

View file

@ -94,4 +94,21 @@ module.exports.setDefault = (path, silent = false) => {
if (!silent) Logger.debug(`[FilePerms] Setting permission "${mode}" for uid ${uid} and gid ${gid} | "${path}"`)
chmodr(path, mode, uid, gid, resolve)
})
}
// Default permissions 0o744 and global Uid/Gid
// Used for setting default permission to initial config/metadata directories
module.exports.setDefaultDirSync = (path, silent = false) => {
const mode = 0o744
const uid = global.Uid
const gid = global.Gid
if (!silent) Logger.debug(`[FilePerms] Setting dir permission "${mode}" for uid ${uid} and gid ${gid} | "${path}"`)
try {
fs.chmodSync(path, mode)
fs.chownSync(path, uid, gid)
return true
} catch (error) {
Logger.error(`[FilePerms] Error setting dir permissions for path "${path}"`, error)
return false
}
}