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 芒果味 ---