### What problem does this PR solve?

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu
2025-07-01 14:05:18 +08:00
committed by GitHub
parent 103027580e
commit e3edcc3064
3 changed files with 8 additions and 3 deletions

View File

@ -300,11 +300,12 @@ async def build_chunks(task, progress_callback):
d["image"].close() # Close original image
d["image"] = converted_image
d["image"].save(output_buffer, format='JPEG')
d["image"].close() # Close PIL image after saving
async with minio_limiter:
await trio.to_thread.run_sync(lambda: STORAGE_IMPL.put(task["kb_id"], d["id"], output_buffer.getvalue()))
d["img_id"] = "{}-{}".format(task["kb_id"], d["id"])
if not isinstance(d["image"], bytes):
d["image"].close()
del d["image"] # Remove image reference
docs.append(d)
finally: