From 7b144cc086f30f0d404a80a85211e3d485f6de28 Mon Sep 17 00:00:00 2001 From: KevinHuSh Date: Thu, 16 May 2024 09:10:29 +0800 Subject: [PATCH] fix: can't capitalize file or folder name (#798) ### What problem does this PR solve? #792 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/document_app.py | 7 ++++--- api/apps/file_app.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/apps/document_app.py b/api/apps/document_app.py index 3cd40e305b..f89c619b22 100644 --- a/api/apps/document_app.py +++ b/api/apps/document_app.py @@ -322,9 +322,10 @@ def rename(): data=False, retmsg="The extension of file can't be changed", retcode=RetCode.ARGUMENT_ERROR) - if DocumentService.query(name=req["name"], kb_id=doc.kb_id): - return get_data_error_result( - retmsg="Duplicated document name in the same knowledgebase.") + for d in DocumentService.query(name=req["name"], kb_id=doc.kb_id): + if d.name == req["name"]: + return get_data_error_result( + retmsg="Duplicated document name in the same knowledgebase.") if not DocumentService.update_by_id( req["doc_id"], {"name": req["name"]}): diff --git a/api/apps/file_app.py b/api/apps/file_app.py index 98a6a9e74a..234ee74191 100644 --- a/api/apps/file_app.py +++ b/api/apps/file_app.py @@ -306,9 +306,10 @@ def rename(): data=False, retmsg="The extension of file can't be changed", retcode=RetCode.ARGUMENT_ERROR) - if FileService.query(name=req["name"], pf_id=file.parent_id): - return get_data_error_result( - retmsg="Duplicated file name in the same folder.") + for file in FileService.query(name=req["name"], pf_id=file.parent_id): + if file.name == req["name"]: + return get_data_error_result( + retmsg="Duplicated file name in the same folder.") if not FileService.update_by_id( req["file_id"], {"name": req["name"]}):