Skip to content

Commit dfe0c18

Browse files
authored
Merge pull request #447 from INCF/remove-ignore-files-after-processing
file size-check to top of validator; remove ignored files from fileslist
2 parents cf21aff + 3fa612f commit dfe0c18

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

validators/bids.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,34 @@ BIDS = {
158158
size: 0
159159
};
160160

161+
162+
// collect file directory statistics
163+
async.eachOfLimit(fileList, 200, function(file) {
164+
// collect file stats
165+
if (typeof window !== 'undefined') {
166+
if (file.size) {
167+
summary.size += file.size;
168+
}
169+
} else {
170+
if (!file.stats) {
171+
try {
172+
file.stats = fs.statSync(file.path);
173+
} catch (err) {
174+
file.stats = {size: 0};
175+
}
176+
}
177+
summary.size += file.stats.size;
178+
}
179+
});
180+
181+
// remove ignored files from list:
182+
Object.keys(fileList).forEach(function(key) {
183+
if (fileList[key].ignore) {
184+
delete fileList[key];
185+
}
186+
});
187+
188+
161189
// var subses_mismatch = false;
162190
self.subIDsesIDmismatchtest(fileList);
163191

@@ -202,13 +230,8 @@ BIDS = {
202230
async.eachOfLimit(fileList, 200, function (file, key, cb) {
203231
var path = file.relativePath;
204232

205-
// ignore files flagged by utils.files.getBIDSIgnore()
206-
if (file.ignore) {
207-
process.nextTick(cb);
208-
}
209-
210233
// ignore associated data
211-
else if (utils.type.isStimuliData(file.relativePath)) {
234+
if (utils.type.isStimuliData(file.relativePath)) {
212235
process.nextTick(cb);
213236
}
214237

@@ -345,22 +368,6 @@ BIDS = {
345368
hasDatasetDescription = true;
346369
}
347370

348-
// collect file stats
349-
if (typeof window !== 'undefined') {
350-
if (file.size) {
351-
summary.size += file.size;
352-
}
353-
} else {
354-
if (!file.stats) {
355-
try {
356-
file.stats = fs.statSync(file.path);
357-
} catch (err) {
358-
file.stats = {size: 0};
359-
}
360-
}
361-
summary.size += file.stats.size;
362-
}
363-
364371
// collect sessions & subjects
365372
if (!utils.type.isStimuliData(file.relativePath) && utils.type.isBIDS(file.relativePath)) {
366373
var pathValues = utils.type.getPathValues(file.relativePath);

0 commit comments

Comments
 (0)