mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Refactor: Improve the try logic for upload_to_minio (#9735)
### What problem does this PR solve? Improve the try logic for upload_to_minio ### Type of change - [x] Refactoring
This commit is contained in:
@ -293,8 +293,7 @@ async def build_chunks(task, progress_callback):
|
|||||||
docs.append(d)
|
docs.append(d)
|
||||||
return
|
return
|
||||||
|
|
||||||
output_buffer = BytesIO()
|
with BytesIO() as output_buffer:
|
||||||
try:
|
|
||||||
if isinstance(d["image"], bytes):
|
if isinstance(d["image"], bytes):
|
||||||
output_buffer.write(d["image"])
|
output_buffer.write(d["image"])
|
||||||
output_buffer.seek(0)
|
output_buffer.seek(0)
|
||||||
@ -317,8 +316,6 @@ async def build_chunks(task, progress_callback):
|
|||||||
d["image"].close()
|
d["image"].close()
|
||||||
del d["image"] # Remove image reference
|
del d["image"] # Remove image reference
|
||||||
docs.append(d)
|
docs.append(d)
|
||||||
finally:
|
|
||||||
output_buffer.close() # Ensure BytesIO is always closed
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception(
|
logging.exception(
|
||||||
"Saving image of chunk {}/{}/{} got exception".format(task["location"], task["name"], d["id"]))
|
"Saving image of chunk {}/{}/{} got exception".format(task["location"], task["name"], d["id"]))
|
||||||
|
|||||||
Reference in New Issue
Block a user