Skip to content

Commit

Permalink
fix(task): limit files 5MB
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 9, 2024
1 parent 2cca483 commit ba9d8ad
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions functions/lib/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ const handleFeedTableQueue = async (notification) => {
const { body, store_id: storeId } = notification
const storageBucket = admin.storage().bucket('gs://ecom-feed-importer.appspot.com')
const [data] = await storageBucket.file(body.file_id).download()
logger.info(`[tableToEcom.parseProduct:start] => ${data.length} bytes`)
const products = await tableToEcom.parseProduct(data, body.contentType)
await handleFeedQueue(storeId, products)
logger.info(`[tableToEcom.parseProduct:start] ${body.file_id} => ${data.length} bytes`)
// 5.242.880 = 5MB
if (data.length < 5242880) {
const products = await tableToEcom.parseProduct(data, body.contentType)
await handleFeedQueue(storeId, products)
} else {
logger.warn(`[s:${storeId}] ${body.file_id} very large file`)
}
} catch (error) {
logger.warn('[tableToEcom.parseProduct:error]')
logger.error(error)
Expand Down

0 comments on commit ba9d8ad

Please sign in to comment.