Add:Server setting to disable folder watcher #378

This commit is contained in:
advplyr 2022-02-23 17:52:21 -06:00
parent 1a89b6e493
commit 7f1fc1901b
4 changed files with 47 additions and 58 deletions

View file

@ -127,8 +127,13 @@ class Server {
await this.scanner.fixDuplicateIds()
}
this.watcher.initWatcher(this.libraries)
this.watcher.on('files', this.filesChanged.bind(this))
if (this.db.serverSettings.scannerDisableWatcher) {
Logger.info(`[Server] Watcher is disabled`)
this.watcher.disabled = true
} else {
this.watcher.initWatcher(this.libraries)
this.watcher.on('files', this.filesChanged.bind(this))
}
}
async start() {

View file

@ -13,6 +13,8 @@ class FolderWatcher extends EventEmitter {
this.pendingFileUpdates = []
this.pendingDelay = 4000
this.pendingTimeout = null
this.disabled = false
}
get pendingFilePaths() {
@ -71,10 +73,12 @@ class FolderWatcher extends EventEmitter {
}
addLibrary(library) {
if (this.disabled) return
this.buildLibraryWatcher(library)
}
updateLibrary(library) {
if (this.disabled) return
var libwatcher = this.libraryWatchers.find(lib => lib.id === library.id)
if (libwatcher) {
libwatcher.name = library.name
@ -90,6 +94,7 @@ class FolderWatcher extends EventEmitter {
}
removeLibrary(library) {
if (this.disabled) return
var libwatcher = this.libraryWatchers.find(lib => lib.id === library.id)
if (libwatcher) {
Logger.info(`[Watcher] Removed watcher for "${library.name}"`)

View file

@ -15,6 +15,7 @@ class ServerSettings {
this.scannerCoverProvider = 'google'
this.scannerPreferAudioMetadata = false
this.scannerPreferOpfMetadata = false
this.scannerDisableWatcher = false
// Metadata
this.coverDestination = CoverDestination.METADATA
@ -56,6 +57,7 @@ class ServerSettings {
this.scannerParseSubtitle = settings.scannerParseSubtitle
this.scannerPreferAudioMetadata = !!settings.scannerPreferAudioMetadata
this.scannerPreferOpfMetadata = !!settings.scannerPreferOpfMetadata
this.scannerDisableWatcher = !!settings.scannerDisableWatcher
this.coverDestination = settings.coverDestination || CoverDestination.METADATA
this.saveMetadataFile = !!settings.saveMetadataFile
@ -92,6 +94,7 @@ class ServerSettings {
scannerParseSubtitle: this.scannerParseSubtitle,
scannerPreferAudioMetadata: this.scannerPreferAudioMetadata,
scannerPreferOpfMetadata: this.scannerPreferOpfMetadata,
scannerDisableWatcher: this.scannerDisableWatcher,
coverDestination: this.coverDestination,
saveMetadataFile: !!this.saveMetadataFile,
rateLimitLoginRequests: this.rateLimitLoginRequests,