From af2d2a1cfbda4792eee4d978169652ad07bac01e Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 13 Jan 2022 14:24:06 +0100 Subject: [PATCH] fix: backport 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 2d417fb..100cdc8 100644 --- a/attachment_azure/models/ir_attachment.py +++ b/attachment_azure/models/ir_attachment.py @@ -134,14 +134,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