From dc0c90452d7b4e013bf4dcc99d0a86e22954f8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com> Date: Wed, 26 Nov 2025 14:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/auto_test/auto_system/service/save_minio.py | 9 +++++++-- README.md | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/MangoServer/src/auto_test/auto_system/service/save_minio.py b/MangoServer/src/auto_test/auto_system/service/save_minio.py index 2ae902a3..fbfb2586 100644 --- a/MangoServer/src/auto_test/auto_system/service/save_minio.py +++ b/MangoServer/src/auto_test/auto_system/service/save_minio.py @@ -20,6 +20,8 @@ if IS_MINIO: class SaveMinio: + _lifecycle_set = False # 类变量,跟踪是否已设置生命周期规则 + def __init__(self, directory_name="screenshot"): self.client = Minio( MINIO_STORAGE_ENDPOINT, @@ -51,7 +53,10 @@ class SaveMinio: tmp_file.write(chunk) temp_file_path = tmp_file.name try: - self.client.set_bucket_lifecycle(MINIO_STORAGE_MEDIA_BUCKET_NAME, self.lifecycle_config) + # 只在第一次调用时设置生命周期规则 + if not SaveMinio._lifecycle_set: + self.client.set_bucket_lifecycle(MINIO_STORAGE_MEDIA_BUCKET_NAME, self.lifecycle_config) + SaveMinio._lifecycle_set = True # 上传文件到MinIO self.client.fput_object( MINIO_STORAGE_MEDIA_BUCKET_NAME, @@ -64,4 +69,4 @@ class SaveMinio: except Exception as e: if os.path.exists(temp_file_path): os.unlink(temp_file_path) - raise MangoServerError(*ERROR_MSG_0004) + raise MangoServerError(*ERROR_MSG_0004) \ No newline at end of file diff --git a/README.md b/README.md index 254da074..d70eebe2 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ ## 📝 版权声明 -VERSION = 5.8.7 +VERSION = 5.8.8 版权所有 © 2022 by 芒果味 ---