From 843f6d9103262a36a67ef157064732c7d7ace70b Mon Sep 17 00:00:00 2001 From: pinks Date: Sun, 15 Oct 2023 13:12:31 +0200 Subject: [PATCH] log upload type and bytes --- app/uploadQueue.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/uploadQueue.ts b/app/uploadQueue.ts index 1cd9647..2c38343 100644 --- a/app/uploadQueue.ts +++ b/app/uploadQueue.ts @@ -63,12 +63,16 @@ export async function processUploadQueue() { ]); // parse files from reply JSON + let size = 0; + const types = new Set(); const inputFiles = await Promise.all( state.imageKeys.map(async (fileKey, idx) => { const imageBuffer = await fs.get(fileKey).then((entry) => entry.value); if (!imageBuffer) throw new Error("File not found"); const imageType = await fileTypeFromBuffer(imageBuffer); if (!imageType) throw new Error("Image has unknown type"); + size += imageBuffer.byteLength; + types.add(imageType.ext); return InputMediaBuilder.photo( new InputFile(imageBuffer, `image${idx}.${imageType.ext}`), // if it can fit, add caption for first photo @@ -121,6 +125,12 @@ export async function processUploadQueue() { globalStats.userIds = [...userIdSet]; } + logger().debug( + `Uploaded ${state.imageKeys.length} ${[...types].join(",")} images (${ + Math.trunc(size / 1024) + }kB) for ${formatUserChat(state)}`, + ); + // delete the status message await bot.api.deleteMessage(state.replyMessage.chat.id, state.replyMessage.message_id) .catch(() => undefined);