mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-26 00:14:49 +01:00
Fix:Save library updating name only #350
This commit is contained in:
parent
964cba0491
commit
663ab2db90
@ -51,13 +51,15 @@ class LibraryController {
|
|||||||
|
|
||||||
async update(req, res) {
|
async update(req, res) {
|
||||||
var library = req.library
|
var library = req.library
|
||||||
|
|
||||||
var hasUpdates = library.update(req.body)
|
var hasUpdates = library.update(req.body)
|
||||||
|
// TODO: Should check if this is an update to folder paths or name only
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
// Update watcher
|
// Update watcher
|
||||||
this.watcher.updateLibrary(library)
|
this.watcher.updateLibrary(library)
|
||||||
|
|
||||||
// Remove audiobooks no longer in library
|
// Remove audiobooks no longer in library
|
||||||
var audiobooksToRemove = this.db.audiobooks.filter(ab => !library.checkFullPathInLibrary(ab.fullPath))
|
var audiobooksToRemove = this.db.audiobooks.filter(ab => ab.libraryId === library.id && !library.checkFullPathInLibrary(ab.fullPath))
|
||||||
if (audiobooksToRemove.length) {
|
if (audiobooksToRemove.length) {
|
||||||
Logger.info(`[Scanner] Updating library, removing ${audiobooksToRemove.length} audiobooks`)
|
Logger.info(`[Scanner] Updating library, removing ${audiobooksToRemove.length} audiobooks`)
|
||||||
for (let i = 0; i < audiobooksToRemove.length; i++) {
|
for (let i = 0; i < audiobooksToRemove.length; i++) {
|
||||||
|
@ -97,7 +97,9 @@ class Library {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
hasUpdates = newFolders.length || removedFolders.length
|
if (newFolders.length || removedFolders.length) {
|
||||||
|
hasUpdates = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
this.lastUpdate = Date.now()
|
this.lastUpdate = Date.now()
|
||||||
@ -106,7 +108,8 @@ class Library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkFullPathInLibrary(fullPath) {
|
checkFullPathInLibrary(fullPath) {
|
||||||
return this.folders.find(folder => fullPath.startsWith(folder.fullPath))
|
fullPath = fullPath.replace(/\\/g, '/')
|
||||||
|
return this.folders.find(folder => fullPath.startsWith(folder.fullPath.replace(/\\/g, '/')))
|
||||||
}
|
}
|
||||||
|
|
||||||
getFolderById(id) {
|
getFolderById(id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user