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 }, } 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 + }), ], [], ) 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',