From 587dd7142428ae07964b6c205172995911d7d91f Mon Sep 17 00:00:00 2001 From: Jamie Stivala Date: Thu, 8 Feb 2024 17:50:53 +0100 Subject: [PATCH 1/4] Fixed an issue where updatejs was not updating due to redirect 302 Fixes #262 --- scripts/updatedb.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/updatedb.js b/scripts/updatedb.js index b207b705..bfa74350 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -181,8 +181,10 @@ function check(database, cb) { function onResponse(response) { var status = response.statusCode; - - if (status !== 200) { + + if(status === 302 || status === 301){ + return https.get(getHTTPOptions(response.headers.location), onResponse); + }else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); client.abort(); process.exit(1); @@ -243,7 +245,9 @@ function fetch(database, cb) { function onResponse(response) { var status = response.statusCode; - if (status !== 200) { + if(status === 302 || status === 301){ + return https.get(getHTTPOptions(response.headers.location), onResponse); + }else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); client.abort(); process.exit(1); From c905fe234430aec29dbea8140bcd43174e59767f Mon Sep 17 00:00:00 2001 From: Jamie Stivala Date: Thu, 8 Feb 2024 18:04:14 +0100 Subject: [PATCH 2/4] Added redirect for status 303, 307 and 308 --- scripts/updatedb.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/updatedb.js b/scripts/updatedb.js index bfa74350..8471a731 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -182,7 +182,7 @@ function check(database, cb) { function onResponse(response) { var status = response.statusCode; - if(status === 302 || status === 301){ + if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308){ return https.get(getHTTPOptions(response.headers.location), onResponse); }else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); @@ -245,7 +245,7 @@ function fetch(database, cb) { function onResponse(response) { var status = response.statusCode; - if(status === 302 || status === 301){ + if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308){ return https.get(getHTTPOptions(response.headers.location), onResponse); }else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); From e4bc3887ced988cef1ddf0524efc6f74c5100c1f Mon Sep 17 00:00:00 2001 From: Jamie Stivala Date: Thu, 8 Feb 2024 18:04:51 +0100 Subject: [PATCH 3/4] Code style to match repo --- scripts/updatedb.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/updatedb.js b/scripts/updatedb.js index 8471a731..d4f35360 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -182,7 +182,7 @@ function check(database, cb) { function onResponse(response) { var status = response.statusCode; - if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308){ + if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308) { return https.get(getHTTPOptions(response.headers.location), onResponse); }else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); @@ -245,7 +245,7 @@ function fetch(database, cb) { function onResponse(response) { var status = response.statusCode; - if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308){ + if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308) { return https.get(getHTTPOptions(response.headers.location), onResponse); }else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); From 2cf76ecf1e221e6730637e05581c9e6fea30290a Mon Sep 17 00:00:00 2001 From: Jamie Stivala Date: Thu, 8 Feb 2024 18:05:35 +0100 Subject: [PATCH 4/4] Code style to match repo Added curly brackets to match the rest of the repository --- scripts/updatedb.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/updatedb.js b/scripts/updatedb.js index d4f35360..a8738225 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -184,7 +184,7 @@ function check(database, cb) { if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308) { return https.get(getHTTPOptions(response.headers.location), onResponse); - }else if (status !== 200) { + } else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); client.abort(); process.exit(1); @@ -247,7 +247,7 @@ function fetch(database, cb) { if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308) { return https.get(getHTTPOptions(response.headers.location), onResponse); - }else if (status !== 200) { + } else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); client.abort(); process.exit(1);