KevinHuSh
commited on
Commit
·
df4234f
1
Parent(s):
ef1c080
fix: can't capitalize file or folder name (#798)
Browse files### 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 +4 -3
- api/apps/file_app.py +4 -3
api/apps/document_app.py
CHANGED
|
@@ -322,9 +322,10 @@ def rename():
|
|
| 322 |
data=False,
|
| 323 |
retmsg="The extension of file can't be changed",
|
| 324 |
retcode=RetCode.ARGUMENT_ERROR)
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
|
|
|
| 328 |
|
| 329 |
if not DocumentService.update_by_id(
|
| 330 |
req["doc_id"], {"name": req["name"]}):
|
|
|
|
| 322 |
data=False,
|
| 323 |
retmsg="The extension of file can't be changed",
|
| 324 |
retcode=RetCode.ARGUMENT_ERROR)
|
| 325 |
+
for d in DocumentService.query(name=req["name"], kb_id=doc.kb_id):
|
| 326 |
+
if d.name == req["name"]:
|
| 327 |
+
return get_data_error_result(
|
| 328 |
+
retmsg="Duplicated document name in the same knowledgebase.")
|
| 329 |
|
| 330 |
if not DocumentService.update_by_id(
|
| 331 |
req["doc_id"], {"name": req["name"]}):
|
api/apps/file_app.py
CHANGED
|
@@ -306,9 +306,10 @@ def rename():
|
|
| 306 |
data=False,
|
| 307 |
retmsg="The extension of file can't be changed",
|
| 308 |
retcode=RetCode.ARGUMENT_ERROR)
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
|
|
|
| 312 |
|
| 313 |
if not FileService.update_by_id(
|
| 314 |
req["file_id"], {"name": req["name"]}):
|
|
|
|
| 306 |
data=False,
|
| 307 |
retmsg="The extension of file can't be changed",
|
| 308 |
retcode=RetCode.ARGUMENT_ERROR)
|
| 309 |
+
for file in FileService.query(name=req["name"], pf_id=file.parent_id):
|
| 310 |
+
if file.name == req["name"]:
|
| 311 |
+
return get_data_error_result(
|
| 312 |
+
retmsg="Duplicated file name in the same folder.")
|
| 313 |
|
| 314 |
if not FileService.update_by_id(
|
| 315 |
req["file_id"], {"name": req["name"]}):
|