Skip to content

Commit

Permalink
fix rename bug (infiniflow#562)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

fix rename file bugs
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
KevinHuSh authored Apr 26, 2024
1 parent ae80ae3 commit e1cb76e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions api/apps/document_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,10 @@ def rm():
except Exception as e:
errors += str(e)


if errors: return server_error_response(e)
return get_json_result(data=True)



@manager.route('/run', methods=['POST'])
@login_required
@validate_request("doc_ids", "run")
Expand Down Expand Up @@ -305,6 +303,11 @@ def rename():
return get_data_error_result(
retmsg="Database error (Document rename)!")

informs = File2DocumentService.get_by_document_id(req["doc_id"])
if informs:
e, file = FileService.get_by_id(informs[0].file_id)
FileService.update_by_id(file.id, {"name": req["name"]})

return get_json_result(data=True)
except Exception as e:
return server_error_response(e)
Expand Down
7 changes: 7 additions & 0 deletions api/apps/file_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ def rename():
return get_data_error_result(
retmsg="Database error (File rename)!")

informs = File2DocumentService.get_by_file_id(req["file_id"])
if informs:
if not DocumentService.update_by_id(
informs[0].document_id, {"name": req["name"]}):
return get_data_error_result(
retmsg="Database error (Document rename)!")

return get_json_result(data=True)
except Exception as e:
return server_error_response(e)
Expand Down
2 changes: 1 addition & 1 deletion api/apps/kb_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def detail():
@login_required
def list():
page_number = request.args.get("page", 1)
items_per_page = request.args.get("page_size", 15)
items_per_page = request.args.get("page_size", 150)
orderby = request.args.get("orderby", "create_time")
desc = request.args.get("desc", True)
try:
Expand Down

0 comments on commit e1cb76e

Please sign in to comment.