fix: put timeout check in the right location

This commit is contained in:
Felipe Andrada 2020-11-30 02:14:21 -03:00
commit 7dc3f70762

View file

@ -107,7 +107,7 @@ function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag
`Downloading ${type} segment ${i}/${segmentsUrl.length} of ${filename}`
);
https
let req = https
.get(segmentsUrl[i], res => {
res.on("data", d => output.write(d));
@ -118,12 +118,17 @@ function combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag
.on("error", e => {
cb(e);
});
req.setTimeout(7000, function () {
log("⚠️", 'Timeout. Retrying');
combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb);
});
}
function getJson(url, cb) {
let data = "";
let req = https
https
.get(url, res => {
res.on("data", d => (data += d));
@ -132,11 +137,6 @@ function getJson(url, cb) {
.on("error", e => {
cb(e);
});
req.setTimeout(7000, function () {
log("⚠️", 'Timeout. Retrying');
combineSegments(type, i, segmentsUrl, output, filename, downloadingFlag, cb);
});
}
function initJs(n = 0) {