mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-10 05:49:37 +00:00
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:
parent
e253939c1e
commit
dcd4f69383
3 changed files with 34 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue