Change Library object use mediaCategory, allow adding new manual folder path, validate folder paths, fix Watcher re-init after folder path updates

This commit is contained in:
advplyr 2022-03-14 09:56:24 -05:00
parent 7348432594
commit deea6702f0
10 changed files with 98 additions and 47 deletions

View file

@ -85,12 +85,15 @@ class FolderWatcher extends EventEmitter {
if (libwatcher) {
libwatcher.name = library.name
// If any folder paths were added or removed then re-init watcher
var pathsToAdd = library.folderPaths.filter(path => !libwatcher.paths.includes(path))
if (pathsToAdd.length) {
Logger.info(`[Watcher] Adding paths to library watcher "${library.name}"`)
libwatcher.paths = library.folderPaths
libwatcher.folders = library.folders
libwatcher.watcher.watchPaths(pathsToAdd)
var pathsRemoved = libwatcher.paths.filter(path => !library.folderPaths.includes(path))
if (pathsToAdd.length || pathsRemoved.length) {
Logger.info(`[Watcher] Re-Initializing watcher for "${library.name}".`)
libwatcher.watcher.close()
this.libraryWatchers = this.libraryWatchers.filter(lw => lw.id !== libwatcher.id)
this.buildLibraryWatcher(library)
}
}
}