Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改停止脚本,修复删除知识库后WebUI相应信息残留问题 #3714

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions server/knowledge_base/kb_api.py
@@ -1,3 +1,6 @@
import os
import stat
import shutil
import urllib
from server.utils import BaseResponse, ListResponse
from server.knowledge_base.utils import validate_kb_name
Expand All @@ -7,6 +10,12 @@
from fastapi import Body


def remove_readonly(func: callable, path: str, _):
"""修复删除知识库文件夹时的权限问题"""
os.chmod(path, stat.S_IWRITE)
func(path)


def list_kbs():
# Get List of Knowledge Base
return ListResponse(data=list_kbs_from_db())
Expand Down Expand Up @@ -55,6 +64,7 @@ def delete_kb(
status = kb.clear_vs()
status = kb.drop_kb()
if status:
shutil.rmtree(kb.kb_path, onerror=remove_readonly)
return BaseResponse(code=200, msg=f"成功删除知识库 {knowledge_base_name}")
except Exception as e:
msg = f"删除知识库时出现意外: {e}"
Expand Down
6 changes: 5 additions & 1 deletion shutdown_all.sh
@@ -1,2 +1,6 @@
# mac设备上的grep命令可能不支持grep -P选项,请使用Homebrew安装;或使用ggrep命令
ps -eo pid,user,cmd|grep -P 'server/api.py|webui.py|fastchat.serve|multiprocessing'|grep -v grep|awk '{print $1}'|xargs kill -9
if [[ "$(uname)" == "Darwin" ]]; then
ps -eo pid,user,command|grep -P 'server/api.py|webui.py|fastchat.serve|multiprocessing'|grep -v grep|awk '{print $1}'|xargs kill -9
else
ps -eo pid,user,cmd|grep -P 'server/api.py|webui.py|fastchat.serve|multiprocessing'|grep -v grep|awk '{print $1}'|xargs kill -9
fi