From 2df7ec4e20f3978df63cf929f7fd22fa93f4ce6f Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Mon, 16 Nov 2020 17:19:36 +0100 Subject: [PATCH 1/2] Fix uncaught error when browsing non-existing repo --- .../GiteaRepoLatestReleaseController.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/controllers/GiteaRepoLatestReleaseController.ts b/src/controllers/GiteaRepoLatestReleaseController.ts index 0359ab0..d284677 100644 --- a/src/controllers/GiteaRepoLatestReleaseController.ts +++ b/src/controllers/GiteaRepoLatestReleaseController.ts @@ -24,18 +24,22 @@ export default class GiteaRepoLatestReleaseController extends Controller { data += c; }); r.on('end', () => { - const assets = JSON.parse(data)[0].assets; + try { + const assets = JSON.parse(data)[0].assets; - if (file) { - for (const asset of assets) { - if (asset.name === file) { - log.debug('Redirect to', asset.browser_download_url); - return res.redirect(302, asset.browser_download_url); + if (file) { + for (const asset of assets) { + if (asset.name === file) { + log.debug('Redirect to', asset.browser_download_url); + return res.redirect(302, asset.browser_download_url); + } } + } else { + log.debug('List files'); + return res.render('list-files', {assets: assets}); } - } else { - log.debug('List files'); - return res.render('list-files', {assets: assets}); + } catch (e) { + return next(e); } }); }).on('error', err => { From 0a761c2ed0b3d09114af65006e42306327b94aef Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Mon, 16 Nov 2020 17:20:03 +0100 Subject: [PATCH 2/2] Version 1.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fcc041..a6f6159 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eternae.ink.update", - "version": "1.0.1", + "version": "1.0.2", "description": "A simple redirection to serve a gitea instance's repositories' latest release files as an http file server. (302 redirections)", "repository": "https://eternae.ink/arisu/update.eternae.ink", "author": "Alice Gaudon ",