Use eachSeries rather than a job array

This commit is contained in:
James Allen 2018-03-13 13:30:06 +00:00
parent 33904fe7be
commit d9b301023a

View file

@ -49,15 +49,17 @@ module.exports = FileSystemImportManager =
return callback("path is symlink")
fs.readdir folderPath, (error, entries = []) =>
return callback(error) if error?
jobs = _.map entries, (entry) =>
(callback) =>
async.eachSeries(
entries,
(entry, callback) =>
FileTypeManager.shouldIgnore entry, (error, ignore) =>
return callback(error) if error?
if !ignore
FileSystemImportManager.addEntity user_id, project_id, parent_folder_id, entry, "#{folderPath}/#{entry}", replace, callback
else
callback()
async.series jobs, callback
callback
)
addEntity: (user_id, project_id, folder_id, name, path, replace, callback = (error, entity)-> ) ->
FileSystemImportManager._isSafeOnFileSystem path, (err, isSafe)->