diff --git a/src/image.ts b/src/image.ts index 247f1a1..66b3b95 100644 --- a/src/image.ts +++ b/src/image.ts @@ -60,6 +60,7 @@ export const processAndUploadImage = async ( (height !== undefined && metadata.height! > height) ) { processedImage = sharp(imageBuffer) + .rotate() .resize(width, height) .toFormat(ext, { quality }); } else { @@ -188,11 +189,27 @@ export const deleteUnmatchedImages = async ( bucketName: string, unmatchedOutputImageKeys: string[] ) => { - const s3Client = await getClient(); + const deleteTasks = unmatchedOutputImageKeys.map( + (unmatchedOutputImageKey, index) => { + limiter.schedule(() => { + const deleteWithLog = async () => { + logger.info( + ansis.gray( + `${index + 1}/${ + unmatchedOutputImageKeys.length + }: deleting key ${unmatchedOutputImageKey}` + ) + ); + const s3Client = await getClient(); + return deleteImage(bucketName, unmatchedOutputImageKey, s3Client); + }; + + return deleteWithLog(); + }); + } + ); - for (const unmatchedOutputImageKey of unmatchedOutputImageKeys) { - await deleteImage(bucketName, unmatchedOutputImageKey, s3Client); - } + await Promise.all(deleteTasks); }; const parseExifData = async (imgData: Buffer): Promise => { diff --git a/src/state.ts b/src/state.ts index 59568a0..793f3fe 100644 --- a/src/state.ts +++ b/src/state.ts @@ -119,7 +119,7 @@ export const getPartialProcessedImages = ( uniqueSourceKeys.size === 1 ? imgs[0].sourceKey : undefined; if (inputKey === undefined) { - logger.warn("unable to find input key for imgs: ", imgs); + logger.debug("unable to find input key for imgs: %o", imgs); continue; }