Skip to content

Commit 3ab8bba

Browse files
authored
Merge pull request #1420 from bids-standard/enh/blacklist-modality
Update modality blacklist.
2 parents a755f65 + 1e6f9e2 commit 3ab8bba

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

bids-validator/utils/files/readDir.js

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -272,40 +272,41 @@ async function getFilesFromFs(dir, rootPath, ig, options) {
272272
path.relative(rootPath, fullPath),
273273
)
274274
const ignore = ig.ignores(path.relative('/', relativePath))
275-
if (!ignore) {
276-
const fileObj = {
277-
name: file.name,
278-
path: fullPath,
279-
relativePath,
280-
}
281-
// Three cases to consider: directories, files, symlinks
282-
if (file.isDirectory()) {
283-
await recursiveMerge(fullPath)
284-
} else if (file.isSymbolicLink()) {
285-
// Allow skipping symbolic links which lead to recursion
286-
// Disabling this is a big performance advantage on high latency
287-
// storage but it's a good default for versatility
288-
if (!options.ignoreSymlinks) {
289-
try {
290-
const targetPath = await fs.promises.realpath(fullPath)
291-
const targetStat = await fs.promises.stat(targetPath)
292-
// Either add or recurse from the target depending
293-
if (targetStat.isDirectory()) {
294-
await recursiveMerge(targetPath)
295-
} else {
296-
filesAccumulator.push(fileObj)
297-
}
298-
} catch (err) {
299-
// Symlink points at an invalid target, skip it
300-
return
275+
const fileObj = {
276+
name: file.name,
277+
path: fullPath,
278+
relativePath,
279+
}
280+
if (ignore) {
281+
fileObj.ignore = true
282+
}
283+
// Three cases to consider: directories, files, symlinks
284+
if (file.isDirectory()) {
285+
await recursiveMerge(fullPath)
286+
} else if (file.isSymbolicLink()) {
287+
// Allow skipping symbolic links which lead to recursion
288+
// Disabling this is a big performance advantage on high latency
289+
// storage but it's a good default for versatility
290+
if (!options.ignoreSymlinks) {
291+
try {
292+
const targetPath = await fs.promises.realpath(fullPath)
293+
const targetStat = await fs.promises.stat(targetPath)
294+
// Either add or recurse from the target depending
295+
if (targetStat.isDirectory()) {
296+
await recursiveMerge(targetPath)
297+
} else {
298+
filesAccumulator.push(fileObj)
301299
}
302-
} else {
303-
// This branch assumes all symbolic links are not directories
304-
filesAccumulator.push(fileObj)
300+
} catch (err) {
301+
// Symlink points at an invalid target, skip it
302+
return
305303
}
306304
} else {
305+
// This branch assumes all symbolic links are not directories
307306
filesAccumulator.push(fileObj)
308307
}
308+
} else {
309+
filesAccumulator.push(fileObj)
309310
}
310311
}
311312
return filesAccumulator

bids-validator/validators/bids/fullTest.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import checkReadme from './checkReadme'
1919
import validateMisc from '../../utils/files/validateMisc'
2020
import collectSubjectMetadata from '../../utils/summary/collectSubjectMetadata'
2121
import collectPetFields from '../../utils/summary/collectPetFields'
22+
import collectModalities from '../../utils/summary/collectModalities'
2223

2324
/**
2425
* Full Test
@@ -44,11 +45,13 @@ const fullTest = (fileList, options, annexed, dir, schema, callback) => {
4445

4546
const tsvs = []
4647

47-
const summary = utils.collectSummary(fileList, self.options, schema)
48-
4948
if (self.options.blacklistModalities) {
49+
const relativePaths = Object.keys(fileList).map(
50+
file => fileList[file].relativePath,
51+
)
52+
const preIgnoreModalities = collectModalities(relativePaths)
5053
self.options.blacklistModalities.map(mod => {
51-
if (summary.modalities.includes(mod)) {
54+
if (preIgnoreModalities.primary.includes(mod)) {
5255
self.issues.push(
5356
new Issue({
5457
file: mod,
@@ -60,6 +63,8 @@ const fullTest = (fileList, options, annexed, dir, schema, callback) => {
6063
})
6164
}
6265

66+
const summary = utils.collectSummary(fileList, self.options, schema)
67+
6368
// remove size redundancies
6469
for (const key in fileList) {
6570
if (fileList.hasOwnProperty(key)) {

0 commit comments

Comments
 (0)