Skip to content

Commit

Permalink
Merge pull request #656 from DaNish808/exists-sync-not-a-function-#655
Browse files Browse the repository at this point in the history
check for 0 kB files in browser
  • Loading branch information
olgn authored Nov 20, 2018
2 parents 4fd11fb + b309aad commit 9e57bfb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 3 additions & 1 deletion utils/files/remoteFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}

Expand Down
20 changes: 5 additions & 15 deletions utils/files/validateMisc.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
const testFile = require('./testFile')
const readFile = require('./readFile')
const Issue = require('../issues/issue')

/**
* validateMisc
*
* 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
}),
],
[],
)
Expand Down
2 changes: 1 addition & 1 deletion utils/issues/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 9e57bfb

Please sign in to comment.