From 80af3cc2d4499bc1f924b88470544c3384c238f9 Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Thu, 28 Nov 2024 19:37:01 +0800 Subject: [PATCH] Don't log exception if object doesn't exist (#3724) ### What problem does this PR solve? Don't log exception if object doesn't exist. Close #1483 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/utils/minio_conn.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rag/utils/minio_conn.py b/rag/utils/minio_conn.py index 11682988..4662c7c8 100644 --- a/rag/utils/minio_conn.py +++ b/rag/utils/minio_conn.py @@ -1,6 +1,7 @@ import logging import time from minio import Minio +from minio.error import S3Error from io import BytesIO from rag import settings from rag.utils import singleton @@ -84,8 +85,11 @@ class RAGFlowMinio(object): return True else: return False + except S3Error as e: + if e.code in ["NoSuchKey", "NoSuchBucket", "ResourceNotFound"]: + return False except Exception: - logging.exception(f"Not found: {bucket}/{filename}") + logging.exception(f"obj_exist {bucket}/{filename} got exception") return False def get_presigned_url(self, bucket, fnm, expires):