From eb5beaf28eb75137032e476cf895da9e5718e9b8 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 13 Jan 2022 14:19:36 +0100 Subject: [PATCH] fix: forward patch cf45547b53f317f828cad20f7d5ee3e968e44b6a --- attachment_azure/models/ir_attachment.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/attachment_azure/models/ir_attachment.py b/attachment_azure/models/ir_attachment.py index dbf480c..c32fd04 100644 --- a/attachment_azure/models/ir_attachment.py +++ b/attachment_azure/models/ir_attachment.py @@ -133,14 +133,13 @@ class IrAttachment(models.Model): container_name = self._get_container_name() blob_service_client = self._get_blob_service_client() container_client = blob_service_client.get_container_client(container_name) - try: - # Create the container - container_client.create_container() - except ResourceExistsError: - pass - except HttpResponseError as error: - _logger.exception("Error during the creation of the Azure container") - raise exceptions.UserError(str(error)) + if not container_client.exists(): + try: + # Create the container + container_client.create_container() + except HttpResponseError as error: + _logger.exception("Error during the creation of the Azure container") + raise exceptions.UserError(str(error)) return container_client @api.model