mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-31 02:01:57 +08:00
Feat: improve the performance for '/upload' API (#6479)
### What problem does this PR solve? improve the logic to fetch parent folder, remove the useless DB IO logic ### Type of change - [x] Performance Improvement
This commit is contained in:
parent
ee6a0bd9db
commit
5d9afce12d
@ -55,20 +55,17 @@ def upload():
|
|||||||
data=False, message='No file selected!', code=settings.RetCode.ARGUMENT_ERROR)
|
data=False, message='No file selected!', code=settings.RetCode.ARGUMENT_ERROR)
|
||||||
file_res = []
|
file_res = []
|
||||||
try:
|
try:
|
||||||
|
e, pf_folder = FileService.get_by_id(pf_id)
|
||||||
|
if not e:
|
||||||
|
return get_data_error_result( message="Can't find this folder!")
|
||||||
for file_obj in file_objs:
|
for file_obj in file_objs:
|
||||||
e, file = FileService.get_by_id(pf_id)
|
|
||||||
if not e:
|
|
||||||
return get_data_error_result(
|
|
||||||
message="Can't find this folder!")
|
|
||||||
MAX_FILE_NUM_PER_USER = int(os.environ.get('MAX_FILE_NUM_PER_USER', 0))
|
MAX_FILE_NUM_PER_USER = int(os.environ.get('MAX_FILE_NUM_PER_USER', 0))
|
||||||
if MAX_FILE_NUM_PER_USER > 0 and DocumentService.get_doc_count(current_user.id) >= MAX_FILE_NUM_PER_USER:
|
if MAX_FILE_NUM_PER_USER > 0 and DocumentService.get_doc_count(current_user.id) >= MAX_FILE_NUM_PER_USER:
|
||||||
return get_data_error_result(
|
return get_data_error_result( message="Exceed the maximum file number of a free user!")
|
||||||
message="Exceed the maximum file number of a free user!")
|
|
||||||
|
|
||||||
# split file name path
|
# split file name path
|
||||||
if not file_obj.filename:
|
if not file_obj.filename:
|
||||||
e, file = FileService.get_by_id(pf_id)
|
file_obj_names = [pf_folder.name, file_obj.filename]
|
||||||
file_obj_names = [file.name, file_obj.filename]
|
|
||||||
else:
|
else:
|
||||||
full_path = '/' + file_obj.filename
|
full_path = '/' + file_obj.filename
|
||||||
file_obj_names = full_path.split('/')
|
file_obj_names = full_path.split('/')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user