@@ -66,13 +66,11 @@ def add_directory(self, path: str) -> int:
6666 image_paths = self ._get_image_paths (path )
6767 logger .info (f"Found { len (image_paths )} images in directory { path } " )
6868
69- existing_paths = {img .path for img in session .query (Image .path ).filter (Image .path .in_ (image_paths )).all ()}
70- new_images = [Image (...) for path in image_paths if path not in existing_paths ]
71- # new_images = [
72- # Image(path=img_path, directory_id=directory.id, is_indexed=False)
73- # for img_path in image_paths
74- # if not session.query(Image).filter(Image.path == img_path).first()
75- # ]
69+ new_images = [
70+ Image (path = img_path , directory_id = directory .id , is_indexed = False )
71+ for img_path in image_paths
72+ if not session .query (Image ).filter (Image .path == img_path ).first ()
73+ ]
7674 session .bulk_save_objects (new_images )
7775 session .commit ()
7876 logger .info (f"Added { len (new_images )} new images to database for directory { path } " )
@@ -215,7 +213,7 @@ def remove_directory(self, path: str):
215213 if directory :
216214 # Remove from Milvus
217215 logger .debug (f"Deleting Milvus entries for directory ID { directory .id } " )
218- for embedder_name in self .embedders :
216+ for embedder_name in self .embedders . keys () :
219217 collection = Collection (embedder_name )
220218 result = collection .delete (f"directory_id == { directory .id } " )
221219 logger .info (f"Deleted { result .delete_count } entries from { embedder_name } collection" )
@@ -436,7 +434,7 @@ def _check_directory_consistency(self, session: Session, directory: Directory):
436434 image = session .query (Image ).filter (Image .path == path ).first ()
437435 if image :
438436 # Remove from Milvus
439- for embedder_name in self .embedders :
437+ for embedder_name in self .embedders . keys () :
440438 collection = Collection (embedder_name )
441439 collection .delete (f"image_path == '{ path } '" )
442440 collection .flush ()
@@ -451,7 +449,7 @@ def _check_directory_consistency(self, session: Session, directory: Directory):
451449 ).all ()
452450
453451 # Check against Milvus
454- for embedder_name in self .embedders :
452+ for embedder_name in self .embedders . keys () :
455453 collection = Collection (embedder_name )
456454 try :
457455 # Get all expected paths for this directory
@@ -562,7 +560,7 @@ def _handle_deleted_image(self, path: str):
562560 try :
563561 image = session .query (Image ).filter (Image .path == path ).first ()
564562 if image :
565- for embedder_name in self .embedders :
563+ for embedder_name in self .embedders . keys () :
566564 collection = Collection (embedder_name )
567565 collection .delete (f"image_path == '{ path } '" )
568566 collection .flush ()
@@ -581,7 +579,7 @@ def _handle_modified_image(self, path: str):
581579 image .is_indexed = False
582580
583581 # Batch delete from Milvus
584- for embedder_name in self .embedders :
582+ for embedder_name in self .embedders . keys () :
585583 collection = Collection (embedder_name )
586584 result = collection .delete (f"directory_id == { self .directory_id } && image_path == '{ path } '" )
587585 logger .info (f"Removed { result .delete_count } embeddings from { embedder_name } for { path } " )
@@ -606,7 +604,7 @@ def _handle_moved_image(self, src_path: str, dest_path: str):
606604 if image :
607605 # Batch update Milvus entries
608606 move_data = []
609- for embedder_name in self .embedders :
607+ for embedder_name in self .embedders . keys () :
610608 collection = Collection (embedder_name )
611609 # Batch retrieve and delete
612610 res = collection .query (
0 commit comments