From fb39f0407898907c0f107672be85194343849eb5 Mon Sep 17 00:00:00 2001 From: David Nishikawa Date: Mon, 19 Nov 2018 12:57:58 -0800 Subject: [PATCH 1/3] modify Issue 44 to include possibility of 0 kB file error --- utils/issues/list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/issues/list.js b/utils/issues/list.js index 1c9fc41f5..6c8b9ea14 100644 --- a/utils/issues/list.js +++ b/utils/issues/list.js @@ -244,7 +244,7 @@ module.exports = { key: 'FILE_READ', severity: 'error', reason: - 'We were unable to read this file. Make sure it is not corrupted, incorrectly named or incorrectly symlinked.', + 'We were unable to read this file. Make sure it contains data (fileSize > 0 kB) and is not corrupted, incorrectly named, or incorrectly symlinked.', }, 45: { key: 'SUBJECT_FOLDERS', From effe109b8df7cd80697b33393dc89cd3f48756b9 Mon Sep 17 00:00:00 2001 From: David Nishikawa Date: Mon, 19 Nov 2018 12:59:46 -0800 Subject: [PATCH 2/3] switch validation of misc files to testing via readFile --- utils/files/validateMisc.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/utils/files/validateMisc.js b/utils/files/validateMisc.js index c7df45f69..e76ea247b 100644 --- a/utils/files/validateMisc.js +++ b/utils/files/validateMisc.js @@ -1,4 +1,4 @@ -const testFile = require('./testFile') +const readFile = require('./readFile') const Issue = require('../issues/issue') /** @@ -6,24 +6,14 @@ const Issue = require('../issues/issue') * * takes a list of files and returns an issue for each file */ -module.exports = function validateMisc(miscFiles) { - const issuePromises = miscFiles.reduce( - (issues, file) => [...issues, testFile(file)], - [], - ) - return Promise.all(issuePromises).then(res => - res - // extract issue - .map(obj => obj.issue) - // remove non-issues - .filter(o => o instanceof Issue), - ) -} module.exports = function validateMisc(miscFiles) { const issuePromises = miscFiles.reduce( (issues, file) => [ ...issues, - new Promise(resolve => testFile(file, false, null, resolve)), + readFile(file, false, null).catch(err => { + if (err instanceof Issue) return err + throw err + }), ], [], ) From b309aad4503241794b7348fadbd94449b4e42d12 Mon Sep 17 00:00:00 2001 From: David Nishikawa Date: Tue, 20 Nov 2018 09:40:05 -0800 Subject: [PATCH 3/3] prevent fs call in bids validator start when in browser --- utils/files/remoteFiles.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/files/remoteFiles.js b/utils/files/remoteFiles.js index 85c531f63..6863c58e9 100644 --- a/utils/files/remoteFiles.js +++ b/utils/files/remoteFiles.js @@ -229,7 +229,9 @@ const remoteFiles = { }, // Check if a local directory is a git-annex repo isGitAnnex: function(path) { - return fs.existsSync(path + '/.git/annex') + if (typeof window === 'undefined') + return fs.existsSync(path + '/.git/annex') + return false }, }