Fix:Updating library folder paths will only set file permissions if it needed to create the folder #529

This commit is contained in:
advplyr 2022-05-19 19:00:34 -05:00
parent 2a235b8324
commit b925dbcc95

View File

@ -86,13 +86,17 @@ class LibraryController {
return f return f
}) })
for (var path of newFolderPaths) { for (var path of newFolderPaths) {
var success = await fs.ensureDir(path).then(() => true).catch((error) => { var pathExists = await fs.pathExists(path)
Logger.error(`[LibraryController] Failed to ensure folder dir "${path}"`, error) if (!pathExists) {
return false // Ensure dir will recursively create directories which might be preferred over mkdir
}) var success = await fs.ensureDir(path).then(() => true).catch((error) => {
if (!success) { Logger.error(`[LibraryController] Failed to ensure folder dir "${path}"`, error)
return res.status(400).send(`Invalid folder directory "${path}"`) return false
} else { })
if (!success) {
return res.status(400).send(`Invalid folder directory "${path}"`)
}
// Set permissions on newly created path
await filePerms.setDefault(path) await filePerms.setDefault(path)
} }
} }