mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-15 03:45:03 +02:00
Fix library folder check if folder exists and if not then attempt to create folder and set permissions, fix library folder check for changes before saving
This commit is contained in:
parent
1c6cd7499b
commit
ff294867f8
2 changed files with 8 additions and 7 deletions
|
@ -142,7 +142,7 @@ export default {
|
|||
var updatePayload = {}
|
||||
for (const key in this.libraryCopy) {
|
||||
if (key === 'folders') {
|
||||
if (this.libraryCopy.folders.join(',') !== this.library.folders.join(',')) {
|
||||
if (this.libraryCopy.folders.map((f) => f.fullPath).join(',') !== this.library.folders.map((f) => f.fullPath).join(',')) {
|
||||
updatePayload.folders = [...this.libraryCopy.folders]
|
||||
}
|
||||
} else if (key === 'settings') {
|
||||
|
|
|
@ -26,15 +26,16 @@ class LibraryController {
|
|||
return f
|
||||
})
|
||||
for (var folder of newLibraryPayload.folders) {
|
||||
var success = await fs.ensureDir(folder.fullPath).then(() => true).catch((error) => {
|
||||
Logger.error(`[LibraryController] Failed to ensure folder dir "${folder.fullPath}"`, error)
|
||||
return false
|
||||
})
|
||||
if (!success) {
|
||||
return res.status(400).send(`Invalid folder directory "${folder.fullPath}"`)
|
||||
} else {
|
||||
try {
|
||||
var direxists = await fs.pathExists(folder.fullPath)
|
||||
if (!direxists) { // If folder does not exist try to make it and set file permissions/owner
|
||||
await fs.mkdir(folder.fullPath)
|
||||
await filePerms.setDefault(folder.fullPath)
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.error(`[LibraryController] Failed to ensure folder dir "${folder.fullPath}"`, error)
|
||||
return res.status(400).send(`Invalid folder directory "${folder.fullPath}"`)
|
||||
}
|
||||
}
|
||||
|
||||
var library = new Library()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue