Skip to content

Commit

Permalink
Fix watcher skip dot files #3230
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Dec 21, 2024
1 parent 0099ae6 commit 7eb315a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server/Watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ class FolderWatcher extends EventEmitter {
return
}
Logger.debug('[Watcher] File Added', path)
this.addFileUpdate(libraryId, path, 'added')
if (!this.addFileUpdate(libraryId, path, 'added')) {
return
}

if (!this.filesBeingAdded.has(path)) {
this.filesBeingAdded.add(path)
Expand Down Expand Up @@ -261,22 +263,23 @@ class FolderWatcher extends EventEmitter {
* @param {string} libraryId
* @param {string} path
* @param {string} type
* @returns {boolean} - If file was added to pending updates
*/
addFileUpdate(libraryId, path, type) {
if (this.pendingFilePaths.includes(path)) return
if (this.pendingFilePaths.includes(path)) return false

// Get file library
const libwatcher = this.libraryWatchers.find((lw) => lw.id === libraryId)
if (!libwatcher) {
Logger.error(`[Watcher] Invalid library id from watcher ${libraryId}`)
return
return false
}

// Get file folder
const folder = libwatcher.libraryFolders.find((fold) => isSameOrSubPath(fold.path, path))
if (!folder) {
Logger.error(`[Watcher] New file folder not found in library "${libwatcher.name}" with path "${path}"`)
return
return false
}

const folderPath = filePathToPOSIX(folder.path)
Expand All @@ -285,14 +288,14 @@ class FolderWatcher extends EventEmitter {

if (Path.extname(relPath).toLowerCase() === '.part') {
Logger.debug(`[Watcher] Ignoring .part file "${relPath}"`)
return
return false
}

// Ignore files/folders starting with "."
const hasDotPath = relPath.split('/').find((p) => p.startsWith('.'))
if (hasDotPath) {
Logger.debug(`[Watcher] Ignoring dot path "${relPath}" | Piece "${hasDotPath}"`)
return
return false
}

Logger.debug(`[Watcher] Modified file in library "${libwatcher.name}" and folder "${folder.id}" with relPath "${relPath}"`)
Expand All @@ -318,6 +321,7 @@ class FolderWatcher extends EventEmitter {
})

this.handlePendingFileUpdatesTimeout()
return true
}

/**
Expand Down

0 comments on commit 7eb315a

Please sign in to comment.