Fix scanner isInvalid flag and recursive path symlink bug

This commit is contained in:
Tiberiu Ichim 2026-02-22 19:59:19 +02:00
parent ed48fd8558
commit d8c89f2b8e
6 changed files with 78 additions and 9 deletions

View file

@ -192,6 +192,15 @@ module.exports.recurseFiles = async (path, relPathToReplace = null) => {
relPathToReplace = path
}
// Handle symlinked directories by using the real path for string replacements
let realPathToReplace = relPathToReplace
try {
realPathToReplace = await fs.realpath(relPathToReplace)
realPathToReplace = filePathToPOSIX(realPathToReplace)
if (!realPathToReplace.endsWith('/')) realPathToReplace += '/'
} catch (err) {}
const options = {
mode: rra.LIST,
recursive: true,
@ -219,7 +228,7 @@ module.exports.recurseFiles = async (path, relPathToReplace = null) => {
item.fullname = filePathToPOSIX(item.fullname)
item.path = filePathToPOSIX(item.path)
const relpath = item.fullname.replace(relPathToReplace, '')
const relpath = item.fullname.replace(realPathToReplace, '')
let reldirname = Path.dirname(relpath)
if (reldirname === '.') reldirname = ''
const dirname = Path.dirname(item.fullname)
@ -249,11 +258,11 @@ module.exports.recurseFiles = async (path, relPathToReplace = null) => {
return true
})
.map((item) => {
var isInRoot = item.path + '/' === relPathToReplace
var isInRoot = item.path + '/' === realPathToReplace
return {
name: item.name,
path: item.fullname.replace(relPathToReplace, ''),
reldirpath: isInRoot ? '' : item.path.replace(relPathToReplace, ''),
path: item.fullname.replace(realPathToReplace, ''),
reldirpath: isInRoot ? '' : item.path.replace(realPathToReplace, ''),
fullpath: item.fullname,
extension: item.extension,
deep: item.deep