mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Add:Disable watcher library specific #378
This commit is contained in:
		
							parent
							
								
									aa675422a9
								
							
						
					
					
						commit
						d368988899
					
				@ -1,7 +1,7 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="w-full h-full px-4 py-2 mb-12">
 | 
			
		||||
    <div class="flex items-center py-1 mb-2">
 | 
			
		||||
      <span v-show="showDirectoryPicker" class="material-icons text-3xl cursor-pointer hover:text-gray-300" @click="backArrowPress">arrow_back</span>
 | 
			
		||||
  <div class="w-full h-full px-4 py-2 mb-4">
 | 
			
		||||
    <div v-show="showDirectoryPicker" class="flex items-center py-1 mb-2">
 | 
			
		||||
      <span class="material-icons text-3xl cursor-pointer hover:text-gray-300" @click="backArrowPress">arrow_back</span>
 | 
			
		||||
      <p class="px-4 text-xl">{{ title }}</p>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,17 @@
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <modals-libraries-folder-chooser v-else :paths="folderPaths" @select="selectFolder" />
 | 
			
		||||
 | 
			
		||||
    <div v-if="!showDirectoryPicker">
 | 
			
		||||
      <div class="flex items-center pt-2">
 | 
			
		||||
        <ui-toggle-switch v-if="!globalWatcherDisabled" v-model="disableWatcher" />
 | 
			
		||||
        <ui-toggle-switch v-else disabled :value="false" />
 | 
			
		||||
        <p class="pl-4 text-lg">Disable folder watcher for library</p>
 | 
			
		||||
      </div>
 | 
			
		||||
      <p v-if="globalWatcherDisabled" class="text-xs text-warning">*Watcher is disabled globally in server settings</p>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
@ -51,7 +61,8 @@ export default {
 | 
			
		||||
      name: '',
 | 
			
		||||
      provider: '',
 | 
			
		||||
      folders: [],
 | 
			
		||||
      showDirectoryPicker: false
 | 
			
		||||
      showDirectoryPicker: false,
 | 
			
		||||
      disableWatcher: false
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  computed: {
 | 
			
		||||
@ -69,10 +80,13 @@ export default {
 | 
			
		||||
      var newfolderpaths = this.folderPaths.join(',')
 | 
			
		||||
      var origfolderpaths = this.library.folders.map((f) => f.fullPath).join(',')
 | 
			
		||||
 | 
			
		||||
      return newfolderpaths === origfolderpaths && this.name === this.library.name && this.provider === this.library.provider
 | 
			
		||||
      return newfolderpaths === origfolderpaths && this.name === this.library.name && this.provider === this.library.provider && this.disableWatcher === this.library.disableWatcher
 | 
			
		||||
    },
 | 
			
		||||
    providers() {
 | 
			
		||||
      return this.$store.state.scanners.providers
 | 
			
		||||
    },
 | 
			
		||||
    globalWatcherDisabled() {
 | 
			
		||||
      return this.$store.getters['getServerSetting']('scannerDisableWatcher')
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
@ -88,6 +102,7 @@ export default {
 | 
			
		||||
      this.name = this.library ? this.library.name : ''
 | 
			
		||||
      this.provider = this.library ? this.library.provider : ''
 | 
			
		||||
      this.folders = this.library ? this.library.folders.map((p) => ({ ...p })) : []
 | 
			
		||||
      this.disableWatcher = this.library ? !!this.library.disableWatcher : false
 | 
			
		||||
      this.showDirectoryPicker = false
 | 
			
		||||
    },
 | 
			
		||||
    selectFolder(fullPath) {
 | 
			
		||||
@ -113,7 +128,8 @@ export default {
 | 
			
		||||
      var newLibraryPayload = {
 | 
			
		||||
        name: this.name,
 | 
			
		||||
        provider: this.provider,
 | 
			
		||||
        folders: this.folders
 | 
			
		||||
        folders: this.folders,
 | 
			
		||||
        disableWatcher: this.disableWatcher
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      this.$emit('update:processing', true)
 | 
			
		||||
@ -146,7 +162,8 @@ export default {
 | 
			
		||||
      var newLibraryPayload = {
 | 
			
		||||
        name: this.name,
 | 
			
		||||
        provider: this.provider,
 | 
			
		||||
        folders: this.folders
 | 
			
		||||
        folders: this.folders,
 | 
			
		||||
        disableWatcher: this.disableWatcher
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      this.$emit('update:processing', true)
 | 
			
		||||
 | 
			
		||||
@ -68,17 +68,19 @@ class FolderWatcher extends EventEmitter {
 | 
			
		||||
 | 
			
		||||
  initWatcher(libraries) {
 | 
			
		||||
    libraries.forEach((lib) => {
 | 
			
		||||
      this.buildLibraryWatcher(lib)
 | 
			
		||||
      if (!lib.disableWatcher) {
 | 
			
		||||
        this.buildLibraryWatcher(lib)
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  addLibrary(library) {
 | 
			
		||||
    if (this.disabled) return
 | 
			
		||||
    if (this.disabled || library.disableWatcher) return
 | 
			
		||||
    this.buildLibraryWatcher(library)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  updateLibrary(library) {
 | 
			
		||||
    if (this.disabled) return
 | 
			
		||||
    if (this.disabled || library.disableWatcher) return
 | 
			
		||||
    var libwatcher = this.libraryWatchers.find(lib => lib.id === library.id)
 | 
			
		||||
    if (libwatcher) {
 | 
			
		||||
      libwatcher.name = library.name
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,7 @@ class Library {
 | 
			
		||||
    this.displayOrder = 1
 | 
			
		||||
    this.icon = 'database'
 | 
			
		||||
    this.provider = 'google'
 | 
			
		||||
    this.disableWatcher = false
 | 
			
		||||
 | 
			
		||||
    this.lastScan = 0
 | 
			
		||||
 | 
			
		||||
@ -31,6 +32,7 @@ class Library {
 | 
			
		||||
    this.displayOrder = library.displayOrder || 1
 | 
			
		||||
    this.icon = library.icon || 'database'
 | 
			
		||||
    this.provider = library.provider || 'google'
 | 
			
		||||
    this.disableWatcher = !!library.disableWatcher
 | 
			
		||||
 | 
			
		||||
    this.createdAt = library.createdAt
 | 
			
		||||
    this.lastUpdate = library.lastUpdate
 | 
			
		||||
@ -44,6 +46,7 @@ class Library {
 | 
			
		||||
      displayOrder: this.displayOrder,
 | 
			
		||||
      icon: this.icon,
 | 
			
		||||
      provider: this.provider,
 | 
			
		||||
      disableWatcher: this.disableWatcher,
 | 
			
		||||
      createdAt: this.createdAt,
 | 
			
		||||
      lastUpdate: this.lastUpdate
 | 
			
		||||
    }
 | 
			
		||||
@ -68,6 +71,7 @@ class Library {
 | 
			
		||||
    }
 | 
			
		||||
    this.displayOrder = data.displayOrder || 1
 | 
			
		||||
    this.icon = data.icon || 'database'
 | 
			
		||||
    this.disableWatcher = !!data.disableWatcher
 | 
			
		||||
    this.createdAt = Date.now()
 | 
			
		||||
    this.lastUpdate = Date.now()
 | 
			
		||||
  }
 | 
			
		||||
@ -82,6 +86,10 @@ class Library {
 | 
			
		||||
      this.provider = payload.provider
 | 
			
		||||
      hasUpdates = true
 | 
			
		||||
    }
 | 
			
		||||
    if (payload.disableWatcher !== this.disableWatcher) {
 | 
			
		||||
      this.disableWatcher = !!payload.disableWatcher
 | 
			
		||||
      hasUpdates = true
 | 
			
		||||
    }
 | 
			
		||||
    if (!isNaN(payload.displayOrder) && payload.displayOrder !== this.displayOrder) {
 | 
			
		||||
      this.displayOrder = Number(payload.displayOrder)
 | 
			
		||||
      hasUpdates = true
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user