improved reporting

This commit is contained in:
Daniel Bulant 2021-05-25 16:06:33 +02:00
parent 83ee0e006f
commit cc6f25bf09
2 changed files with 2 additions and 6 deletions

View file

@ -31,16 +31,14 @@ export class CBZGenerator extends BaseGenerator {
this.callback(chapterI, i, false);
const hash = chapter.links[i];
const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`;
const start = performance.now();
const res = await this.fetchImage(URL);
const image = new ZipPassThrough(`${this.opts.title} ${chapter.number.toString().padStart(chapterCountLength, "0")}/${i.toString().padStart(imageCountLength, "0")}.${hash.substr(hash.lastIndexOf(".") + 1)}`);
this.zip.add(image);
const data = new Uint8Array(await res.arrayBuffer());
const end = performance.now() - start;
report({
bytes: data.byteLength,
cached: res.headers.get("X-Cache") === "HIT",
duration: end,
duration: performance.getEntriesByName(URL)[0].duration,
success: Math.floor(res.status / 100) === 2,
url: URL
});

View file

@ -41,16 +41,14 @@ export class EpubGenerator extends BaseGenerator {
this.callback(chapterI, i, false);
const hash = chapter.links[i];
const URL = `${baseUrl}/${this.opts.quality}/${chapter.hash}/${hash}`;
const start = performance.now();
const res = await this.fetchImage(URL);
const image = new ZipPassThrough("OEBPS/" + hash);
this.zip.add(image);
const data = new Uint8Array(await res.arrayBuffer());
const end = performance.now() - start;
report({
bytes: data.byteLength,
cached: res.headers.get("X-Cache") === "HIT",
duration: end,
duration: performance.getEntriesByName(URL)[0].duration,
success: Math.floor(res.status / 100) === 2,
url: URL
});