mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: KB folder may not there while creating virtual file (#9431)
### What problem does this PR solve? KB folder may not there while creating virtual file. #9423 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -227,10 +227,13 @@ class FileService(CommonService):
|
|||||||
# tenant_id: Tenant ID
|
# tenant_id: Tenant ID
|
||||||
# Returns:
|
# Returns:
|
||||||
# Knowledge base folder dictionary
|
# Knowledge base folder dictionary
|
||||||
for root in cls.model.select().where((cls.model.tenant_id == tenant_id), (cls.model.parent_id == cls.model.id)):
|
root_folder = cls.get_root_folder(tenant_id)
|
||||||
for folder in cls.model.select().where((cls.model.tenant_id == tenant_id), (cls.model.parent_id == root.id), (cls.model.name == KNOWLEDGEBASE_FOLDER_NAME)):
|
root_id = root_folder["id"]
|
||||||
return folder.to_dict()
|
kb_folder = cls.model.select().where((cls.model.tenant_id == tenant_id), (cls.model.parent_id == root_id), (cls.model.name == KNOWLEDGEBASE_FOLDER_NAME)).first()
|
||||||
assert False, "Can't find the KB folder. Database init error."
|
if not kb_folder:
|
||||||
|
kb_folder = cls.new_a_file_from_kb(tenant_id, KNOWLEDGEBASE_FOLDER_NAME, root_id)
|
||||||
|
return kb_folder
|
||||||
|
return kb_folder.to_dict()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@DB.connection_context()
|
@DB.connection_context()
|
||||||
@ -499,10 +502,9 @@ class FileService(CommonService):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_blob(user_id, location):
|
def get_blob(user_id, location):
|
||||||
bname = f"{user_id}-downloads"
|
bname = f"{user_id}-downloads"
|
||||||
return STORAGE_IMPL.get(bname, location)
|
return STORAGE_IMPL.get(bname, location)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def put_blob(user_id, location, blob):
|
def put_blob(user_id, location, blob):
|
||||||
bname = f"{user_id}-downloads"
|
bname = f"{user_id}-downloads"
|
||||||
return STORAGE_IMPL.put(bname, location, blob)
|
return STORAGE_IMPL.put(bname, location, blob)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user