From be50d274672eb074a94c1f5f7a556fefab018ad2 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Tue, 2 Nov 2021 15:55:29 +0200 Subject: [PATCH] do not count stats only for a single page --- lib/handlers/on-fetch.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/handlers/on-fetch.js b/lib/handlers/on-fetch.js index 0d8dd5f4..a558299e 100644 --- a/lib/handlers/on-fetch.js +++ b/lib/handlers/on-fetch.js @@ -130,6 +130,10 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi let lastUid = false; + let startTime = Date.now(); + let rowCount = 0; + let totalBytes = 0; + // instead of fetching all messages at once from a large mailbox // we page it into smaller queries let processPage = () => { @@ -174,9 +178,6 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi cursor = cursor.batchSize(1000); } - let startTime = Date.now(); - let rowCount = 0; - let totalBytes = 0; let processedCount = 0; let processNext = () => { cursor.next((err, messageData) => {