@@ -186,12 +186,11 @@ pub trait AttachmentStrategy {
186186 ) -> impl Future < Output = Result < Option < Managed < Item > > , multer:: Error > > + Send ;
187187}
188188
189- pub async fn read_attachment_bytes_into_item (
189+ pub async fn read_bytes_into_item (
190190 field : Field < ' static > ,
191191 mut item : Managed < Item > ,
192192 config : & Config ,
193- ignore_size_exceeded : bool ,
194- ) -> Result < Option < Managed < Item > > , multer:: Error > {
193+ ) -> Result < Managed < Item > , multer:: Error > {
195194 let content_type = field
196195 . content_type ( )
197196 . map ( |ct| ct. as_ref ( ) . parse ( ) . unwrap_or ( ContentType :: OctetStream ) ) ;
@@ -213,19 +212,19 @@ pub async fn read_attachment_bytes_into_item(
213212 } ;
214213 records. lenient ( DataCategory :: Attachment ) ;
215214 } ) ;
215+
216216 if n_bytes > limit {
217217 let attachment_type = item. attachment_type ( ) . unwrap_or ( AttachmentType :: Attachment ) ;
218218 let item_type = DiscardItemType :: Attachment ( DiscardAttachmentType :: from ( attachment_type) ) ;
219219 let _ = item. reject_err ( Outcome :: Invalid ( DiscardReason :: TooLarge ( item_type) ) ) ;
220- return match ignore_size_exceeded {
221- true => Ok ( None ) ,
222- false => Err ( multer :: Error :: FieldSizeExceeded {
223- limit : limit as u64 ,
224- field_name ,
225- } ) ,
226- } ;
220+
221+ Err ( multer :: Error :: FieldSizeExceeded {
222+ limit : limit as u64 ,
223+ field_name ,
224+ } )
225+ } else {
226+ Ok ( item )
227227 }
228- Ok ( Some ( item) )
229228}
230229
231230pub async fn multipart_items (
@@ -412,14 +411,13 @@ mod tests {
412411
413412 struct MockAttachmentStrategy ;
414413 impl AttachmentStrategy for MockAttachmentStrategy {
415- fn add_to_item (
414+ async fn add_to_item (
416415 & self ,
417416 field : Field < ' static > ,
418417 item : Managed < Item > ,
419418 config : & Config ,
420- ) -> impl Future < Output = Result < Option < Managed < Item > > , multer:: Error > > + Send
421- {
422- read_attachment_bytes_into_item ( field, item, config, false )
419+ ) -> Result < Option < Managed < Item > > , multer:: Error > {
420+ read_bytes_into_item ( field, item, config) . await . map ( Some )
423421 }
424422
425423 fn infer_type ( & self , _: & Field ) -> AttachmentType {
@@ -465,14 +463,13 @@ mod tests {
465463
466464 struct MockAttachmentStrategy ;
467465 impl AttachmentStrategy for MockAttachmentStrategy {
468- fn add_to_item (
466+ async fn add_to_item (
469467 & self ,
470468 field : Field < ' static > ,
471469 item : Managed < Item > ,
472470 config : & Config ,
473- ) -> impl Future < Output = Result < Option < Managed < Item > > , multer:: Error > > + Send
474- {
475- read_attachment_bytes_into_item ( field, item, config, true )
471+ ) -> Result < Option < Managed < Item > > , multer:: Error > {
472+ read_bytes_into_item ( field, item, config) . await . map ( Some )
476473 }
477474
478475 fn infer_type ( & self , _: & Field ) -> AttachmentType {
0 commit comments