Scanner ignore .part files #2063

This commit is contained in:
advplyr 2023-09-08 14:50:59 -05:00
parent 80fee92037
commit 2a11932822
2 changed files with 17 additions and 6 deletions

View File

@ -1,3 +1,4 @@
const Path = require('path')
const EventEmitter = require('events') const EventEmitter = require('events')
const Watcher = require('./libs/watcher/watcher') const Watcher = require('./libs/watcher/watcher')
const Logger = require('./Logger') const Logger = require('./Logger')
@ -177,10 +178,16 @@ class FolderWatcher extends EventEmitter {
Logger.error(`[Watcher] New file folder not found in library "${libwatcher.name}" with path "${path}"`) Logger.error(`[Watcher] New file folder not found in library "${libwatcher.name}" with path "${path}"`)
return return
} }
const folderFullPath = filePathToPOSIX(folder.fullPath) const folderFullPath = filePathToPOSIX(folder.fullPath)
const relPath = path.replace(folderFullPath, '') const relPath = path.replace(folderFullPath, '')
if (Path.extname(relPath).toLowerCase() === '.part') {
Logger.debug(`[Watcher] Ignoring .part file "${relPath}"`)
return
}
// Ignore files/folders starting with "." // Ignore files/folders starting with "."
const hasDotPath = relPath.split('/').find(p => p.startsWith('.')) const hasDotPath = relPath.split('/').find(p => p.startsWith('.'))
if (hasDotPath) { if (hasDotPath) {

View File

@ -138,7 +138,7 @@ async function recurseFiles(path, relPathToReplace = null) {
realPath: true, realPath: true,
normalizePath: true normalizePath: true
} }
var list = await rra.list(path, options) let list = await rra.list(path, options)
if (list.error) { if (list.error) {
Logger.error('[fileUtils] Recurse files error', list.error) Logger.error('[fileUtils] Recurse files error', list.error)
return [] return []
@ -152,10 +152,10 @@ async function recurseFiles(path, relPathToReplace = null) {
return false return false
} }
var relpath = item.fullname.replace(relPathToReplace, '') const relpath = item.fullname.replace(relPathToReplace, '')
var reldirname = Path.dirname(relpath) let reldirname = Path.dirname(relpath)
if (reldirname === '.') reldirname = '' if (reldirname === '.') reldirname = ''
var dirname = Path.dirname(item.fullname) const dirname = Path.dirname(item.fullname)
// Directory has a file named ".ignore" flag directory and ignore // Directory has a file named ".ignore" flag directory and ignore
if (item.name === '.ignore' && reldirname && reldirname !== '.' && !directoriesToIgnore.includes(dirname)) { if (item.name === '.ignore' && reldirname && reldirname !== '.' && !directoriesToIgnore.includes(dirname)) {
@ -164,9 +164,13 @@ async function recurseFiles(path, relPathToReplace = null) {
return false return false
} }
if (item.extension === '.part') {
Logger.debug(`[fileUtils] Ignoring .part file "${relpath}"`)
return false
}
// Ignore any file if a directory or the filename starts with "." // Ignore any file if a directory or the filename starts with "."
var pathStartsWithPeriod = relpath.split('/').find(p => p.startsWith('.')) if (relpath.split('/').find(p => p.startsWith('.'))) {
if (pathStartsWithPeriod) {
Logger.debug(`[fileUtils] Ignoring path has . "${relpath}"`) Logger.debug(`[fileUtils] Ignoring path has . "${relpath}"`)
return false return false
} }