assetguard.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /**
  2. * AssetGuard
  3. *
  4. * This module aims to provide a comprehensive and stable method for processing
  5. * and downloading game assets for the WesterosCraft server. A central object
  6. * stores download meta for several identifiers (categories). This meta data
  7. * is initially empty until one of the module's processing functions are called.
  8. * That function will process the corresponding asset index and validate any exisitng
  9. * local files. If a file is missing or fails validation, it will be placed into an
  10. * array which acts as a queue. This queue is wrapped in a download tracker object
  11. * so that essential information can be cached. The download tracker object is then
  12. * assigned as the value of the identifier in the central object. These download
  13. * trackers will remain idle until an async process is started to process them.
  14. *
  15. * Once the async process is started, any enqueued assets will be downloaded. The central
  16. * object will emit events throughout the download whose name correspond to the identifier
  17. * being processed. For example, if the 'assets' identifier was being processed, whenever
  18. * the download stream recieves data, the event 'assetsdlprogress' will be emitted off of
  19. * the central object instance. This can be listened to by external modules allowing for
  20. * categorical tracking of the downloading process.
  21. *
  22. * @module assetguard
  23. */
  24. // Requirements
  25. const fs = require('fs')
  26. const request = require('request')
  27. const path = require('path')
  28. const mkpath = require('mkdirp');
  29. const async = require('async')
  30. const crypto = require('crypto')
  31. const AdmZip = require('adm-zip')
  32. const child_process = require('child_process')
  33. const EventEmitter = require('events')
  34. const {remote} = require('electron')
  35. // Classes
  36. /** Class representing a base asset. */
  37. class Asset{
  38. /**
  39. * Create an asset.
  40. *
  41. * @param {any} id - id of the asset.
  42. * @param {String} hash - hash value of the asset.
  43. * @param {Number} size - size in bytes of the asset.
  44. * @param {String} from - url where the asset can be found.
  45. * @param {String} to - absolute local file path of the asset.
  46. */
  47. constructor(id, hash, size, from, to){
  48. this.id = id
  49. this.hash = hash
  50. this.size = size
  51. this.from = from
  52. this.to = to
  53. }
  54. }
  55. /** Class representing a mojang library. */
  56. class Library extends Asset{
  57. /**
  58. * Converts the process.platform OS names to match mojang's OS names.
  59. */
  60. static mojangFriendlyOS(){
  61. const opSys = process.platform
  62. if (opSys === 'darwin') {
  63. return 'osx';
  64. } else if (opSys === 'win32'){
  65. return 'windows';
  66. } else if (opSys === 'linux'){
  67. return 'linux';
  68. } else {
  69. return 'unknown_os';
  70. }
  71. }
  72. /**
  73. * Checks whether or not a library is valid for download on a particular OS, following
  74. * the rule format specified in the mojang version data index. If the allow property has
  75. * an OS specified, then the library can ONLY be downloaded on that OS. If the disallow
  76. * property has instead specified an OS, the library can be downloaded on any OS EXCLUDING
  77. * the one specified.
  78. *
  79. * @param {Object} rules - the Library's download rules.
  80. * @returns {Boolean} - true if the Library follows the specified rules, otherwise false.
  81. */
  82. static validateRules(rules){
  83. if(rules == null) return true
  84. let result = true
  85. rules.forEach(function(rule){
  86. const action = rule['action']
  87. const osProp = rule['os']
  88. if(action != null){
  89. if(osProp != null){
  90. const osName = osProp['name']
  91. const osMoj = Library.mojangFriendlyOS()
  92. if(action === 'allow'){
  93. result = osName === osMoj
  94. return
  95. } else if(action === 'disallow'){
  96. result = osName !== osMoj
  97. return
  98. }
  99. }
  100. }
  101. })
  102. return result
  103. }
  104. }
  105. /**
  106. * Class representing a download tracker. This is used to store meta data
  107. * about a download queue, including the queue itself.
  108. */
  109. class DLTracker {
  110. /**
  111. * Create a DLTracker
  112. *
  113. * @param {Array.<Asset>} dlqueue - an array containing assets queued for download.
  114. * @param {Number} dlsize - the combined size of each asset in the download queue array.
  115. */
  116. constructor(dlqueue, dlsize){
  117. this.dlqueue = dlqueue
  118. this.dlsize = dlsize
  119. }
  120. }
  121. /**
  122. * Central object class used for control flow. This object stores data about
  123. * categories of downloads. Each category is assigned an identifier with a
  124. * DLTracker object as its value. Combined information is also stored, such as
  125. * the total size of all the queued files in each category. This event is used
  126. * to emit events so that external modules can listen into processing done in
  127. * this module.
  128. */
  129. class AssetGuard extends EventEmitter{
  130. /**
  131. * AssetGuard class should only ever have one instance which is defined in
  132. * this module. On creation the object's properties are never-null default
  133. * values. Each identifier is resolved to an empty DLTracker.
  134. */
  135. constructor(){
  136. super()
  137. this.totaldlsize = 0;
  138. this.progress = 0;
  139. this.assets = new DLTracker([], 0)
  140. this.libraries = new DLTracker([], 0)
  141. this.files = new DLTracker([], 0)
  142. this.forge = new DLTracker([], 0)
  143. }
  144. }
  145. /**
  146. * Global static final instance of AssetGuard
  147. */
  148. const instance = new AssetGuard()
  149. // Utility Functions
  150. /**
  151. * Resolve an artifact id into a path. For example, on windows
  152. * net.minecraftforge:forge:1.11.2-13.20.0.2282
  153. * becomes
  154. * net\minecraftforge\forge\1.11.2-13.20.0.2282\forge-1.11.2-13.20.0.2282.jar
  155. *
  156. * @param {String} artifact - the artifact id string.
  157. * @param {String} extension - the extension of the file at the resolved path.
  158. * @returns {String} - the resolved relative path from the artifact id.
  159. */
  160. function _resolvePath(artifact, extension){
  161. let ps = artifact.split(':')
  162. let cs = ps[0].split('.')
  163. cs.push(ps[1])
  164. cs.push(ps[2])
  165. cs.push(ps[1].concat('-').concat(ps[2]).concat(extension))
  166. return path.join.apply(path, cs)
  167. }
  168. /**
  169. * Calculates the hash for a file using the specified algorithm.
  170. *
  171. * @param {Buffer} buf - the buffer containing file data.
  172. * @param {String} algo - the hash algorithm.
  173. * @returns {String} - the calculated hash in hex.
  174. */
  175. function _calculateHash(buf, algo){
  176. return crypto.createHash(algo).update(buf).digest('hex')
  177. }
  178. /**
  179. * Used to parse a checksums file. This is specifically designed for
  180. * the checksums.sha1 files found inside the forge scala dependencies.
  181. *
  182. * @param {String} content - the string content of the checksums file.
  183. * @returns {Object} - an object with keys being the file names, and values being the hashes.
  184. */
  185. function _parseChecksumsFile(content){
  186. let finalContent = {}
  187. let lines = content.split('\n')
  188. for(let i=0; i<lines.length; i++){
  189. let bits = lines[i].split(' ')
  190. if(bits[1] == null) {
  191. continue
  192. }
  193. finalContent[bits[1]] = bits[0]
  194. }
  195. return finalContent
  196. }
  197. /**
  198. * Validate that a file exists and matches a given hash value.
  199. *
  200. * @param {String} filePath - the path of the file to validate.
  201. * @param {String} algo - the hash algorithm to check against.
  202. * @param {String} hash - the existing hash to check against.
  203. * @returns {Boolean} - true if the file exists and calculated hash matches the given hash, otherwise false.
  204. */
  205. function _validateLocal(filePath, algo, hash){
  206. if(fs.existsSync(filePath)){
  207. let fileName = path.basename(filePath)
  208. let buf = fs.readFileSync(filePath)
  209. let calcdhash = _calculateHash(buf, algo)
  210. return calcdhash === hash
  211. }
  212. return false;
  213. }
  214. /**
  215. * Validates a file in the style used by forge's version index.
  216. *
  217. * @param {String} filePath - the path of the file to validate.
  218. * @param {Array.<String>} checksums - the checksums listed in the forge version index.
  219. * @returns {Boolean} - true if the file exists and the hashes match, otherwise false.
  220. */
  221. function _validateForgeChecksum(filePath, checksums){
  222. if(fs.existsSync(filePath)){
  223. if(checksums == null || checksums.length === 0){
  224. return true
  225. }
  226. let buf = fs.readFileSync(filePath)
  227. let calcdhash = _calculateHash(buf, 'sha1')
  228. let valid = checksums.includes(calcdhash)
  229. if(!valid && filePath.endsWith('.jar')){
  230. valid = _validateForgeJar(filePath, checksums)
  231. }
  232. return valid
  233. }
  234. return false
  235. }
  236. /**
  237. * Validates a forge jar file dependency who declares a checksums.sha1 file.
  238. * This can be an expensive task as it usually requires that we calculate thousands
  239. * of hashes.
  240. *
  241. * @param {Buffer} buf - the buffer of the jar file.
  242. * @param {Array.<String>} checksums - the checksums listed in the forge version index.
  243. * @returns {Boolean} - true if all hashes declared in the checksums.sha1 file match the actual hashes.
  244. */
  245. function _validateForgeJar(buf, checksums){
  246. const hashes = {}
  247. let expected = {}
  248. const zip = new AdmZip(buf)
  249. const zipEntries = zip.getEntries()
  250. //First pass
  251. for(let i=0; i<zipEntries.length; i++){
  252. let entry = zipEntries[i]
  253. if(entry.entryName === 'checksums.sha1'){
  254. expected = _parseChecksumsFile(zip.readAsText(entry))
  255. }
  256. hashes[entry.entryName] = _calculateHash(entry.getData(), 'sha1')
  257. }
  258. if(!checksums.includes(hashes['checksums.sha1'])){
  259. return false
  260. }
  261. //Check against expected
  262. const expectedEntries = Object.keys(expected)
  263. for(let i=0; i<expectedEntries.length; i++){
  264. if(expected[expectedEntries[i]] !== hashes[expectedEntries[i]]){
  265. return false
  266. }
  267. }
  268. return true
  269. }
  270. function _extractPackXZ(filePath){
  271. return new Promise(function(fulfill, reject){
  272. const libPath = path.join(__dirname, '..', 'libraries', 'java', 'PackXZExtract.jar')
  273. console.log(libPath)
  274. const child = child_process.spawn('C:\\Program Files\\Java\\jre1.8.0_131\\bin\\javaw.exe', ['-jar', libPath, '-packxz', filePath])
  275. child.stdout.on('data', (data) => {
  276. console.log('minecraft:', data.toString('utf8'))
  277. })
  278. child.stderr.on('data', (data) => {
  279. console.log('minecraft:', data.toString('utf8'))
  280. })
  281. child.on('close', (code, signal) => {
  282. console.log('exited with code', code)
  283. fulfill()
  284. })
  285. })
  286. }
  287. /**
  288. * Initiate an async download process for an AssetGuard DLTracker.
  289. *
  290. * @param {String} identifier - the identifier of the AssetGuard DLTracker.
  291. * @param {Number} limit - optional. The number of async processes to run in parallel.
  292. * @returns {Boolean} - true if the process began, otherwise false.
  293. */
  294. function startAsyncProcess(identifier, limit = 5){
  295. let win = remote.getCurrentWindow()
  296. let acc = 0
  297. const concurrentDlQueue = instance[identifier].dlqueue.slice(0)
  298. if(concurrentDlQueue.length === 0){
  299. return false
  300. } else {
  301. async.eachLimit(concurrentDlQueue, limit, function(asset, cb){
  302. mkpath.sync(path.join(asset.to, ".."))
  303. let req = request(asset.from)
  304. let writeStream = fs.createWriteStream(asset.to)
  305. req.pipe(writeStream)
  306. req.on('data', function(chunk){
  307. instance.progress += chunk.length
  308. acc += chunk.length
  309. instance.emit(identifier + 'dlprogress', acc)
  310. //console.log(identifier + ' Progress', acc/instance[identifier].dlsize)
  311. win.setProgressBar(instance.progress/instance.totaldlsize)
  312. })
  313. writeStream.on('close', cb)
  314. }, function(err){
  315. if(err){
  316. instance.emit(identifier + 'dlerror')
  317. console.log('An item in ' + identifier + ' failed to process');
  318. } else {
  319. instance.emit(identifier + 'dlcomplete')
  320. console.log('All ' + identifier + ' have been processed successfully')
  321. }
  322. instance.totaldlsize -= instance[identifier].dlsize
  323. instance[identifier] = new DLTracker([], 0)
  324. if(instance.totaldlsize === 0) {
  325. win.setProgressBar(-1)
  326. instance.emit('dlcomplete')
  327. }
  328. })
  329. return true
  330. }
  331. }
  332. // Validation Functions
  333. /**
  334. * Loads the version data for a given minecraft version.
  335. *
  336. * @param {String} version - the game version for which to load the index data.
  337. * @param {String} basePath - the absolute file path which will be prepended to the given relative paths.
  338. * @param {Boolean} force - optional. If true, the version index will be downloaded even if it exists locally. Defaults to false.
  339. * @returns {Promise.<Object>} - Promise which resolves to the version data object.
  340. */
  341. function loadVersionData(version, basePath, force = false){
  342. return new Promise(function(fulfill, reject){
  343. const name = version + '.json'
  344. const url = 'https://s3.amazonaws.com/Minecraft.Download/versions/' + version + '/' + name
  345. const versionPath = path.join(basePath, 'versions', version)
  346. const versionFile = path.join(versionPath, name)
  347. if(!fs.existsSync(versionFile) || force){
  348. //This download will never be tracked as it's essential and trivial.
  349. request.head(url, function(err, res, body){
  350. console.log('Preparing download of ' + version + ' assets.')
  351. mkpath.sync(versionPath)
  352. const stream = request(url).pipe(fs.createWriteStream(versionFile))
  353. stream.on('finish', function(){
  354. fulfill(JSON.parse(fs.readFileSync(versionFile)))
  355. })
  356. })
  357. } else {
  358. fulfill(JSON.parse(fs.readFileSync(versionFile)))
  359. }
  360. })
  361. }
  362. /**
  363. * Public asset validation function. This function will handle the validation of assets.
  364. * It will parse the asset index specified in the version data, analyzing each
  365. * asset entry. In this analysis it will check to see if the local file exists and is valid.
  366. * If not, it will be added to the download queue for the 'assets' identifier.
  367. *
  368. * @param {Object} versionData - the version data for the assets.
  369. * @param {String} basePath - the absolute file path which will be prepended to the given relative paths.
  370. * @param {Boolean} force - optional. If true, the asset index will be downloaded even if it exists locally. Defaults to false.
  371. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  372. */
  373. function validateAssets(versionData, basePath, force = false){
  374. return new Promise(function(fulfill, reject){
  375. _assetChainIndexData(versionData, basePath, force).then(() => {
  376. fulfill()
  377. })
  378. })
  379. }
  380. //Chain the asset tasks to provide full async. The below functions are private.
  381. /**
  382. * Private function used to chain the asset validation process. This function retrieves
  383. * the index data.
  384. * @param {Object} versionData
  385. * @param {String} basePath
  386. * @param {Boolean} force
  387. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  388. */
  389. function _assetChainIndexData(versionData, basePath, force = false){
  390. return new Promise(function(fulfill, reject){
  391. //Asset index constants.
  392. const assetIndex = versionData.assetIndex
  393. const name = assetIndex.id + '.json'
  394. const indexPath = path.join(basePath, 'assets', 'indexes')
  395. const assetIndexLoc = path.join(indexPath, name)
  396. let data = null
  397. if(!fs.existsSync(assetIndexLoc) || force){
  398. console.log('Downloading ' + versionData.id + ' asset index.')
  399. mkpath.sync(indexPath)
  400. const stream = request(assetIndex.url).pipe(fs.createWriteStream(assetIndexLoc))
  401. stream.on('finish', function() {
  402. data = JSON.parse(fs.readFileSync(assetIndexLoc, 'utf-8'))
  403. _assetChainValidateAssets(versionData, basePath, data).then(() => {
  404. fulfill()
  405. })
  406. })
  407. } else {
  408. data = JSON.parse(fs.readFileSync(assetIndexLoc, 'utf-8'))
  409. _assetChainValidateAssets(versionData, basePath, data).then(() => {
  410. fulfill()
  411. })
  412. }
  413. })
  414. }
  415. /**
  416. * Private function used to chain the asset validation process. This function processes
  417. * the assets and enqueues missing or invalid files.
  418. * @param {Object} versionData
  419. * @param {String} basePath
  420. * @param {Boolean} force
  421. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  422. */
  423. function _assetChainValidateAssets(versionData, basePath, indexData){
  424. return new Promise(function(fulfill, reject){
  425. //Asset constants
  426. const resourceURL = 'http://resources.download.minecraft.net/'
  427. const localPath = path.join(basePath, 'assets')
  428. const indexPath = path.join(localPath, 'indexes')
  429. const objectPath = path.join(localPath, 'objects')
  430. const assetDlQueue = []
  431. let dlSize = 0;
  432. //const objKeys = Object.keys(data.objects)
  433. async.forEachOfLimit(indexData.objects, 10, function(value, key, cb){
  434. const hash = value.hash
  435. const assetName = path.join(hash.substring(0, 2), hash)
  436. const urlName = hash.substring(0, 2) + "/" + hash
  437. const ast = new Asset(key, hash, String(value.size), resourceURL + urlName, path.join(objectPath, assetName))
  438. if(!_validateLocal(ast.to, 'sha1', ast.hash)){
  439. dlSize += (ast.size*1)
  440. assetDlQueue.push(ast)
  441. }
  442. cb()
  443. }, function(err){
  444. instance.assets = new DLTracker(assetDlQueue, dlSize)
  445. instance.totaldlsize += dlSize
  446. fulfill()
  447. })
  448. })
  449. }
  450. /**
  451. * Public library validation function. This function will handle the validation of libraries.
  452. * It will parse the version data, analyzing each library entry. In this analysis, it will
  453. * check to see if the local file exists and is valid. If not, it will be added to the download
  454. * queue for the 'libraries' identifier.
  455. *
  456. * @param {Object} versionData - the version data for the assets.
  457. * @param {String} basePath - the absolute file path which will be prepended to the given relative paths.
  458. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  459. */
  460. function validateLibraries(versionData, basePath){
  461. return new Promise(function(fulfill, reject){
  462. const libArr = versionData.libraries
  463. const libPath = path.join(basePath, 'libraries')
  464. const libDlQueue = []
  465. let dlSize = 0
  466. //Check validity of each library. If the hashs don't match, download the library.
  467. async.eachLimit(libArr, 5, function(lib, cb){
  468. if(Library.validateRules(lib.rules)){
  469. let artifact = (lib.natives == null) ? lib.downloads.artifact : lib.downloads.classifiers[lib.natives[Library.mojangFriendlyOS()]]
  470. const libItm = new Library(lib.name, artifact.sha1, artifact.size, artifact.url, path.join(libPath, artifact.path))
  471. if(!_validateLocal(libItm.to, 'sha1', libItm.hash)){
  472. dlSize += (libItm.size*1)
  473. libDlQueue.push(libItm)
  474. }
  475. }
  476. cb()
  477. }, function(err){
  478. instance.libraries = new DLTracker(libDlQueue, dlSize)
  479. instance.totaldlsize += dlSize
  480. fulfill()
  481. })
  482. })
  483. }
  484. /**
  485. * Public miscellaneous mojang file validation function. These files will be enqueued under
  486. * the 'files' identifier.
  487. *
  488. * @param {Object} versionData - the version data for the assets.
  489. * @param {String} basePath - the absolute file path which will be prepended to the given relative paths.
  490. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  491. */
  492. function validateMiscellaneous(versionData, basePath){
  493. return new Promise(async function(fulfill, reject){
  494. await validateClient(versionData, basePath)
  495. await validateLogConfig(versionData, basePath)
  496. fulfill()
  497. })
  498. }
  499. /**
  500. * Validate client file - artifact renamed from client.jar to '{version}'.jar.
  501. *
  502. * @param {Object} versionData - the version data for the assets.
  503. * @param {String} basePath - the absolute file path which will be prepended to the given relative paths.
  504. * @param {Boolean} force - optional. If true, the asset index will be downloaded even if it exists locally. Defaults to false.
  505. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  506. */
  507. function validateClient(versionData, basePath, force = false){
  508. return new Promise(function(fulfill, reject){
  509. const clientData = versionData.downloads.client
  510. const version = versionData.id
  511. const targetPath = path.join(basePath, 'versions', version)
  512. const targetFile = version + '.jar'
  513. let client = new Asset(version + ' client', clientData.sha1, clientData.size, clientData.url, path.join(targetPath, targetFile))
  514. if(!_validateLocal(client.to, 'sha1', client.hash) || force){
  515. instance.files.dlqueue.push(client)
  516. instance.files.dlsize += client.size*1
  517. fulfill()
  518. } else {
  519. fulfill()
  520. }
  521. })
  522. }
  523. /**
  524. * Validate log config.
  525. *
  526. * @param {Object} versionData - the version data for the assets.
  527. * @param {String} basePath - the absolute file path which will be prepended to the given relative paths.
  528. * @param {Boolean} force - optional. If true, the asset index will be downloaded even if it exists locally. Defaults to false.
  529. * @returns {Promise.<Void>} - An empty promise to indicate the async processing has completed.
  530. */
  531. function validateLogConfig(versionData, basePath){
  532. return new Promise(function(fulfill, reject){
  533. const client = versionData.logging.client
  534. const file = client.file
  535. const targetPath = path.join(basePath, 'assets', 'log_configs')
  536. let logConfig = new Asset(file.id, file.sha1, file.size, file.url, path.join(targetPath, file.id))
  537. if(!_validateLocal(logConfig.to, 'sha1', logConfig.hash)){
  538. instance.files.dlqueue.push(logConfig)
  539. instance.files.dlsize += client.size*1
  540. fulfill()
  541. } else {
  542. fulfill()
  543. }
  544. })
  545. }
  546. function validateForge(){
  547. }
  548. function _validateForgeAssets(forgePath){
  549. }
  550. /**
  551. * This function will initiate the download processed for the specified identifiers. If no argument is
  552. * given, all identifiers will be initiated. Note that in order for files to be processed you need to run
  553. * the processing function corresponding to that identifier. If you run this function without processing
  554. * the files, it is likely nothing will be enqueued in the global object and processing will complete
  555. * immediately. Once all downloads are complete, this function will fire the 'dlcomplete' event on the
  556. * global object instance.
  557. *
  558. * @param {Array.<{id: string, limit: number}>} identifiers - optional. The identifiers to process and corresponding parallel async task limit.
  559. */
  560. function processDlQueues(identifiers = [{id:'assets', limit:20}, {id:'libraries', limit:5}, {id:'files', limit:5}]){
  561. this.progress = 0;
  562. let win = remote.getCurrentWindow()
  563. let shouldFire = true
  564. for(let i=0; i<identifiers.length; i++){
  565. let iden = identifiers[i]
  566. let r = startAsyncProcess(iden.id, iden.limit)
  567. if(r) shouldFire = false
  568. }
  569. if(shouldFire){
  570. instance.emit('dlcomplete')
  571. }
  572. }
  573. module.exports = {
  574. loadVersionData,
  575. validateAssets,
  576. validateLibraries,
  577. validateMiscellaneous,
  578. processDlQueues,
  579. instance,
  580. Asset,
  581. Library
  582. }