@@ -380,7 +380,7 @@ class CopyItems(BaseReportableUseCase):
380380 Return skipped item names.
381381 """
382382
383- CHUNK_SIZE = 1000
383+ CHUNK_SIZE = 500
384384
385385 def __init__ (
386386 self ,
@@ -431,12 +431,18 @@ def execute(self):
431431 )
432432 items = [item .name for item in self ._items .get_all (condition )]
433433
434- existing_items = self ._backend_service .get_bulk_images (
435- project_id = self ._project .id ,
436- team_id = self ._project .team_id ,
437- folder_id = self ._to_folder .uuid ,
438- images = items ,
439- )
434+ existing_items = []
435+ for i in range (0 , len (items ), self .CHUNK_SIZE ):
436+ cand_items = self ._backend_service .get_bulk_images (
437+ project_id = self ._project .id ,
438+ team_id = self ._project .team_id ,
439+ folder_id = self ._to_folder .uuid ,
440+ images = items [i : i + self .CHUNK_SIZE ],
441+ )
442+ if isinstance (cand_items , dict ):
443+ continue
444+ existing_items += cand_items
445+
440446 duplications = [item ["name" ] for item in existing_items ]
441447 items_to_copy = list (set (items ) - set (duplications ))
442448 skipped_items = duplications
@@ -471,12 +477,19 @@ def execute(self):
471477 except BackendError as e :
472478 self ._response .errors = AppException (e )
473479 return self ._response
474- existing_items = self ._backend_service .get_bulk_images (
475- project_id = self ._project .id ,
476- team_id = self ._project .team_id ,
477- folder_id = self ._to_folder .uuid ,
478- images = items ,
479- )
480+
481+ existing_items = []
482+ for i in range (0 , len (items ), self .CHUNK_SIZE ):
483+ cand_items = self ._backend_service .get_bulk_images (
484+ project_id = self ._project .id ,
485+ team_id = self ._project .team_id ,
486+ folder_id = self ._to_folder .uuid ,
487+ images = items [i : i + self .CHUNK_SIZE ],
488+ )
489+ if isinstance (cand_items , dict ):
490+ continue
491+ existing_items += cand_items
492+
480493 existing_item_names_set = {item ["name" ] for item in existing_items }
481494 items_to_copy_names_set = set (items_to_copy )
482495 copied_items = existing_item_names_set .intersection (
@@ -603,14 +616,18 @@ def validate_items(self):
603616 existing_items = []
604617 for i in range (0 , len (self ._item_names ), self .CHUNK_SIZE ):
605618
606- search_names = self ._item_names [i : i + self .CHUNK_SIZE ]
607- existing_items + = self ._backend_service .get_bulk_images (
619+ search_names = self ._item_names [i : i + self .CHUNK_SIZE ]
620+ cand_items = self ._backend_service .get_bulk_images (
608621 project_id = self ._project .id ,
609622 team_id = self ._project .team_id ,
610623 folder_id = self ._folder .uuid ,
611624 images = search_names ,
612625 )
613626
627+ if isinstance (cand_items , dict ):
628+ continue
629+ existing_items += cand_items
630+
614631 if not existing_items :
615632 raise AppValidationException (self .ERROR_MESSAGE )
616633 if existing_items :
0 commit comments