Merge pull request #21 from felipeands/master

feat: auto retry on download timeout
This commit is contained in:
Tusko Trush 2020-11-30 13:05:53 +02:00 committed by GitHub
commit c103351cc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,6 +118,11 @@ 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) {