mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Refactor:Improve insert file logic (#8445)
### What problem does this PR solve? before refactor 1. create file record 2. Add to blob if have some execption at 2 the system db will have a file record but not have related blob, which will introduce some bug. after refactor 1. add to blob 2. create file record. if 1 success but 2 failed just have a dirty blob in blob system, user will not feel that ### Type of change - [x] Refactoring
This commit is contained in:
@ -99,6 +99,7 @@ def upload():
|
|||||||
FileService.query,
|
FileService.query,
|
||||||
name=file_obj_names[file_len - 1],
|
name=file_obj_names[file_len - 1],
|
||||||
parent_id=last_folder.id)
|
parent_id=last_folder.id)
|
||||||
|
STORAGE_IMPL.put(last_folder.id, location, blob)
|
||||||
file = {
|
file = {
|
||||||
"id": get_uuid(),
|
"id": get_uuid(),
|
||||||
"parent_id": last_folder.id,
|
"parent_id": last_folder.id,
|
||||||
@ -110,7 +111,6 @@ def upload():
|
|||||||
"size": len(blob),
|
"size": len(blob),
|
||||||
}
|
}
|
||||||
file = FileService.insert(file)
|
file = FileService.insert(file)
|
||||||
STORAGE_IMPL.put(last_folder.id, location, blob)
|
|
||||||
file_res.append(file.to_json())
|
file_res.append(file.to_json())
|
||||||
return get_json_result(data=file_res)
|
return get_json_result(data=file_res)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user