From 5619acb71103fc5b52378cd0f091b12be838f898 Mon Sep 17 00:00:00 2001 From: Pierce Date: Sat, 26 Oct 2019 17:53:04 -0400 Subject: [PATCH] change default maven repo so typesafe doesnt break. solves #26 and #27 --- components/handler.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/handler.js b/components/handler.js index c6d81c2..d422d73 100644 --- a/components/handler.js +++ b/components/handler.js @@ -45,6 +45,11 @@ class Handler { let total_bytes = 0; _request.on('response', (data) => { + if (data.statusCode === 404) { + this.client.emit('debug', `[MCLC]: Failed to download ${url} due to: File not found...`); + resolve(false); + } + total_bytes = parseInt(data.headers['content-length']); }); @@ -327,7 +332,7 @@ class Handler { } } - const downloadLink = `${url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${lib[1]}-${lib[2]}.jar`; + const downloadLink = `${url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`; if(fs.existsSync(path.join(jarPath, name))) { paths.push(`${jarPath}${path.sep}${name}`); @@ -337,7 +342,8 @@ class Handler { } if(!fs.existsSync(jarPath)) shelljs.mkdir('-p', jarPath); - await this.downloadAsync(downloadLink, jarPath, name, true, 'forge'); + const download = await this.downloadAsync(downloadLink, jarPath, name, true, 'forge'); + if(!download) await this.downloadAsync(`https://search.maven.org/remotecontent?filepath=${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`, jarPath, name, true, 'forge'); paths.push(`${jarPath}${path.sep}${name}`); counter = counter + 1;