@@ -7038,6 +7038,23 @@ async def update_knowledge_base(
70387038 self.logger.error(f"❌ Failed to update knowledge base: {str(e)}")
70397039 raise
70407040
7041+ async def get_folder_record_by_id(self, folder_id: str, transaction: Optional[TransactionDatabase] = None) -> Optional[Dict]:
7042+ try:
7043+ db = transaction if transaction else self.db
7044+ query = """
7045+ FOR file IN @@files
7046+ FILTER file._key == @folder_id
7047+ RETURN file
7048+ """
7049+ cursor = db.aql.execute(query, bind_vars={
7050+ "folder_id": folder_id,
7051+ "@files": CollectionNames.FILES.value,
7052+ })
7053+ return next(cursor, None)
7054+ except Exception as e:
7055+ self.logger.error(f"❌ Failed to fetch folder record {folder_id}: {str(e)}")
7056+ return None
7057+
70417058 async def find_folder_by_name_in_parent(
70427059 self,
70437060 kb_id: str,
@@ -7141,7 +7158,7 @@ async def navigate_to_folder_by_path(
71417158 current_parent_id = folder["_key"]
71427159
71437160 # Return the final folder if we successfully navigated the entire path
7144- return await self.get_file_record_by_id (current_parent_id, transaction)
7161+ return await self.get_folder_record_by_id (current_parent_id, transaction)
71457162
71467163 except Exception as e:
71477164 self.logger.error(f"❌ Failed to navigate to folder by path: {str(e)}")
@@ -7180,7 +7197,7 @@ async def create_folder(
71807197 try:
71817198 # Step 1: Validate parent folder exists (if nested)
71827199 if parent_folder_id:
7183- parent_folder = await self.get_file_record_by_id (parent_folder_id, transaction)
7200+ parent_folder = await self.get_folder_record_by_id (parent_folder_id, transaction)
71847201 if not parent_folder:
71857202 raise ValueError(f"Parent folder {parent_folder_id} not found")
71867203 if parent_folder.get("isFile") is not False:
@@ -12378,13 +12395,8 @@ async def get_file_record_by_id(
1237812395 db = transaction if transaction else self.db
1237912396 cursor = db.aql.execute(query, bind_vars={"id": id})
1238012397 result = next(cursor, None)
12381- print("!!!!!!!!!!!!!!!!!!! result:", result)
1238212398 if result and result.get("file") and result.get("record"):
1238312399 self.logger.info("✅ Successfully retrieved file record for id %s", id)
12384- print("!!!!!!!!!!!!!!!!!!! FileRecord.from_arango_base_file_record:", FileRecord.from_arango_base_file_record(
12385- arango_base_file_record=result["file"],
12386- arango_base_record=result["record"]
12387- ))
1238812400 return FileRecord.from_arango_base_file_record(
1238912401 arango_base_file_record=result["file"],
1239012402 arango_base_record=result["record"]
0 commit comments