Updated uploadController.js

Better snekfetch's error handling, probably.
This commit is contained in:
Bobby Wibowo 2018-06-06 00:40:33 +07:00
parent 57834dd362
commit 9396a9ab49
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -216,7 +216,8 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => {
} }
const head = await snekfetch.head(url) const head = await snekfetch.head(url)
.catch(erred) .catch(error => error)
if (head.status !== 200) { return erred(head.toString()) }
if (!head) { return } if (!head) { return }
const size = parseInt(head.headers['content-length']) const size = parseInt(head.headers['content-length'])
@ -228,7 +229,8 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => {
} }
const download = await snekfetch.get(url) const download = await snekfetch.get(url)
.catch(erred) .catch(error => error)
if (download.status !== 200) { return erred(download.toString()) }
if (!download) { return } if (!download) { return }
const length = uploadsController.getFileNameLength(req) const length = uploadsController.getFileNameLength(req)