@@ -576,19 +576,20 @@ module.exports = {
576576
577577 let enrichedFiles = Array . isArray ( releaseDoc . files ) ? releaseDoc . files : [ ] ;
578578
579+ // If there are files to enrich, try to get their metadata
579580 if ( enrichedFiles . length > 0 ) {
580581 try {
581582 const filesColl = mongo . databases . events . collection ( 'releases.files' ) ;
582583
583- const ids = [ ...new Set (
584+ const fileIds = [ ...new Set (
584585 enrichedFiles
585- . filter ( f => f && typeof f === 'object' && f . _id )
586- . map ( f => String ( f . _id ) )
586+ . filter ( file => file && typeof file === 'object' && file . _id )
587+ . map ( file => String ( file . _id ) )
587588 ) ] . map ( id => new ObjectId ( id ) ) ;
588589
589- if ( ids . length > 0 ) {
590+ if ( fileIds . length > 0 ) {
590591 const filesInfo = await filesColl . find (
591- { _id : { $in : ids } } ,
592+ { _id : { $in : fileIds } } ,
592593 {
593594 projection : {
594595 length : 1 ,
@@ -598,9 +599,9 @@ module.exports = {
598599 ) . toArray ( ) ;
599600
600601 const metaById = new Map (
601- filesInfo . map ( doc => [ String ( doc . _id ) , {
602- length : doc . length ,
603- uploadDate : doc . uploadDate ,
602+ filesInfo . map ( fileInfo => [ String ( fileInfo . _id ) , {
603+ length : fileInfo . length ,
604+ uploadDate : fileInfo . uploadDate ,
604605 } ] )
605606 ) ;
606607
0 commit comments