@@ -78,6 +78,7 @@ async def get_knowledge(
7878 login_user : UserPayload ,
7979 knowledge_type : KnowledgeTypeEnum ,
8080 name : str = None ,
81+ sort_by : str = "update_time" ,
8182 page : int = 1 ,
8283 limit : int = 10 ,
8384 ) -> (List [KnowledgeRead ], int ):
@@ -96,6 +97,7 @@ async def get_knowledge(
9697 knowledge_id_extra ,
9798 knowledge_type ,
9899 name ,
100+ sort_by ,
99101 page ,
100102 limit ,
101103 )
@@ -104,7 +106,7 @@ async def get_knowledge(
104106 )
105107 else :
106108 res = await KnowledgeDao .aget_all_knowledge (
107- name , knowledge_type , page = page , limit = limit
109+ name , knowledge_type , sort_by , page = page , limit = limit
108110 )
109111 total = await KnowledgeDao .acount_all_knowledge (name , knowledge_type )
110112
@@ -461,7 +463,7 @@ async def get_preview_file_chunk(
461463 new_file_name = KnowledgeUtils .get_tmp_preview_file_object_name (filepath )
462464 minio_client = await get_minio_storage ()
463465 if await minio_client .object_exists (minio_client .tmp_bucket , new_file_name ):
464- file_share_url = minio_client .get_share_link (
466+ file_share_url = await minio_client .get_share_link (
465467 new_file_name , minio_client .tmp_bucket
466468 )
467469
@@ -623,9 +625,7 @@ async def rebuild_knowledge_file(cls, request: Request,
623625 db_file .updater_name = login_user .user_name
624626 db_file = await KnowledgeFileDao .async_update (db_file )
625627
626- file_path , _ = cls .get_file_share_url (db_file .id )
627-
628- preview_cache_key = cls .get_preview_cache_key (req_data .knowledge_id , file_path = file_path )
628+ preview_cache_key = cls .get_preview_cache_key (req_data .knowledge_id , file_path = req_data .file_path )
629629 file_worker .retry_knowledge_file_celery .delay (db_file .id , preview_cache_key , req_data .callback_url )
630630
631631 return db_file .model_dump ()
@@ -1172,13 +1172,13 @@ def get_file_share_url(cls, file_id: int) -> (str, str):
11721172 """ 获取文件原始下载地址 和 对应的预览文件下载地址 """
11731173 file = KnowledgeFileDao .get_file_by_ids ([file_id ])
11741174 if not file :
1175- raise NotFoundError . http_exception ()
1175+ raise NotFoundError ()
11761176 file = file [0 ]
11771177 minio_client = get_minio_storage_sync ()
11781178 # 130版本以前的文件解析
11791179 if file .parse_type in [ParseType .LOCAL .value , ParseType .UNS .value ]:
1180- original_url = minio_client .get_share_link (cls .get_knowledge_file_object_name (file .id , file .file_name ))
1181- preview_url = minio_client .get_share_link (str (file .id ))
1180+ original_url = minio_client .get_share_link_sync (cls .get_knowledge_file_object_name (file .id , file .file_name ))
1181+ preview_url = minio_client .get_share_link_sync (str (file .id ))
11821182 else :
11831183 original_url = cls .get_file_share_url_with_empty (file .object_name )
11841184 preview_url = ""
@@ -1197,7 +1197,7 @@ def get_file_share_url_with_empty(cls, object_name: str) -> str:
11971197 """
11981198 minio_client = get_minio_storage_sync ()
11991199 if minio_client .object_exists_sync (minio_client .bucket , object_name ):
1200- return minio_client .get_share_link (object_name , minio_client . bucket )
1200+ return minio_client .get_share_link_sync (object_name )
12011201 return ""
12021202
12031203 @classmethod
0 commit comments