ignore when save image fail (#2178)

### What problem does this PR solve?


### Type of change
- [x] Performance Improvement
This commit is contained in:
Kevin Hu 2024-08-30 18:41:31 +08:00 committed by GitHub
parent 5400467da1
commit fc6d8ee77f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -206,15 +206,20 @@ def build(row):
docs.append(d)
continue
output_buffer = BytesIO()
if isinstance(d["image"], bytes):
output_buffer = BytesIO(d["image"])
else:
d["image"].save(output_buffer, format='JPEG')
try:
output_buffer = BytesIO()
if isinstance(d["image"], bytes):
output_buffer = BytesIO(d["image"])
else:
d["image"].save(output_buffer, format='JPEG')
st = timer()
MINIO.put(row["kb_id"], d["_id"], output_buffer.getvalue())
el += timer() - st
except Exception as e:
cron_logger.error(str(e))
traceback.print_exc()
st = timer()
MINIO.put(row["kb_id"], d["_id"], output_buffer.getvalue())
el += timer() - st
d["img_id"] = "{}-{}".format(row["kb_id"], d["_id"])
del d["image"]
docs.append(d)