MCPcopy
hub / github.com/advplyr/audiobookshelf / handlePendingFileUpdatesTimeout

Method handlePendingFileUpdatesTimeout

server/Watcher.js:326–349  ·  view source on GitHub ↗

* Wait X seconds before notifying scanner that files changed * reset timer if files are still copying

()

Source from the content-addressed store, hash-verified

324 * reset timer if files are still copying
325 */
326 handlePendingFileUpdatesTimeout() {
327 clearTimeout(this.pendingTimeout)
328 this.pendingTimeout = setTimeout(() => {
329 // Check that files are not still being added
330 if (this.pendingFileUpdates.some((pfu) => this.filesBeingAdded.has(pfu.path))) {
331 Logger.debug(`[Watcher] Still waiting for pending files "${[...this.filesBeingAdded].join(', ')}"`)
332 return this.handlePendingFileUpdatesTimeout()
333 }
334
335 if (this.pendingFileUpdates.length) {
336 this.emit('scanFilesChanged', this.pendingFileUpdates, this.pendingTask)
337 } else {
338 const taskFinishedString = {
339 text: 'No files to scan',
340 key: 'MessageTaskNoFilesToScan'
341 }
342 this.pendingTask.setFinished(taskFinishedString)
343 TaskManager.taskFinished(this.pendingTask)
344 }
345 this.pendingTask = null
346 this.pendingFileUpdates = []
347 this.filesBeingAdded.clear()
348 }, this.pendingDelay)
349 }
350
351 /**
352 *

Callers 1

addFileUpdateMethod · 0.95

Calls 6

joinMethod · 0.80
emitMethod · 0.80
taskFinishedMethod · 0.80
debugMethod · 0.65
setFinishedMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected