mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix:Downloading podcasts with watcher causing duplicate episodes #2122
This commit is contained in:
		
							parent
							
								
									1dc369180c
								
							
						
					
					
						commit
						3d96749d38
					
				| @ -191,7 +191,7 @@ export default { | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     search() {}, | ||||
|     submit() {}, | ||||
|     inputUpdate() { | ||||
|       clearTimeout(this.searchTimeout) | ||||
|       this.searchTimeout = setTimeout(() => { | ||||
|  | ||||
| @ -92,7 +92,7 @@ class Logger { | ||||
|    * @param  {...any} args | ||||
|    */ | ||||
|   dev(...args) { | ||||
|     if (!this.isDev) return | ||||
|     if (!this.isDev || process.env.HIDE_DEV_LOGS === '1') return | ||||
|     console.log(`[${this.timestamp}] DEV:`, ...args) | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -28,6 +28,8 @@ class FolderWatcher extends EventEmitter { | ||||
|     this.ignoreDirs = [] | ||||
|     /** @type {string[]} */ | ||||
|     this.pendingDirsToRemoveFromIgnore = [] | ||||
|     /** @type {NodeJS.Timeout} */ | ||||
|     this.removeFromIgnoreTimer = null | ||||
| 
 | ||||
|     this.disabled = false | ||||
|   } | ||||
| @ -240,9 +242,12 @@ class FolderWatcher extends EventEmitter { | ||||
|    */ | ||||
|   addIgnoreDir(path) { | ||||
|     path = this.cleanDirPath(path) | ||||
|     if (this.ignoreDirs.includes(path)) return | ||||
|     this.pendingDirsToRemoveFromIgnore = this.pendingDirsToRemoveFromIgnore.filter(p => p !== path) | ||||
|     Logger.debug(`[Watcher] Ignoring directory "${path}"`) | ||||
|     if (this.ignoreDirs.includes(path)) { | ||||
|       // Already ignoring dir
 | ||||
|       return | ||||
|     } | ||||
|     Logger.debug(`[Watcher] addIgnoreDir: Ignoring directory "${path}"`) | ||||
|     this.ignoreDirs.push(path) | ||||
|   } | ||||
| 
 | ||||
| @ -255,18 +260,24 @@ class FolderWatcher extends EventEmitter { | ||||
|    */ | ||||
|   removeIgnoreDir(path) { | ||||
|     path = this.cleanDirPath(path) | ||||
|     if (!this.ignoreDirs.includes(path) || this.pendingDirsToRemoveFromIgnore.includes(path)) return | ||||
|     if (!this.ignoreDirs.includes(path)) { | ||||
|       Logger.debug(`[Watcher] removeIgnoreDir: Path is not being ignored "${path}"`) | ||||
|       return | ||||
|     } | ||||
| 
 | ||||
|     // Add a 5 second delay before removing the ignore from this dir
 | ||||
|     this.pendingDirsToRemoveFromIgnore.push(path) | ||||
|     setTimeout(() => { | ||||
|     if (!this.pendingDirsToRemoveFromIgnore.includes(path)) { | ||||
|       this.pendingDirsToRemoveFromIgnore.push(path) | ||||
|     } | ||||
| 
 | ||||
|     clearTimeout(this.removeFromIgnoreTimer) | ||||
|     this.removeFromIgnoreTimer = setTimeout(() => { | ||||
|       if (this.pendingDirsToRemoveFromIgnore.includes(path)) { | ||||
|         this.pendingDirsToRemoveFromIgnore = this.pendingDirsToRemoveFromIgnore.filter(p => p !== path) | ||||
|         Logger.debug(`[Watcher] No longer ignoring directory "${path}"`) | ||||
|         Logger.debug(`[Watcher] removeIgnoreDir: No longer ignoring directory "${path}"`) | ||||
|         this.ignoreDirs = this.ignoreDirs.filter(p => p !== path) | ||||
|       } | ||||
|     }, 5000) | ||||
| 
 | ||||
|   } | ||||
| } | ||||
| module.exports = FolderWatcher | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user