From 91e7c5313d9a699a591538c0bcc35fc66e1bbe51 Mon Sep 17 00:00:00 2001 From: aamo-odoo Date: Mon, 4 Mar 2024 11:00:49 +0530 Subject: [PATCH] [FIX] base : new attachement directory creation Fix race-condition when a directory is created by two processes (python's os.py handles it for all directories, but not for the last one). Happens sometimes when generating assets for the first time (CSS, JS); one of the two times might crash. sentry-4417110945 closes odoo/odoo#156232 Signed-off-by: Fabien Pinckaers (fp) --- odoo/addons/base/models/ir_attachment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_attachment.py b/odoo/addons/base/models/ir_attachment.py index fecb1b01bcc..915d27bdf13 100644 --- a/odoo/addons/base/models/ir_attachment.py +++ b/odoo/addons/base/models/ir_attachment.py @@ -109,7 +109,7 @@ class IrAttachment(models.Model): full_path = self._full_path(fname) dirname = os.path.dirname(full_path) if not os.path.isdir(dirname): - os.makedirs(dirname) + os.makedirs(dirname, exist_ok=True) # prevent sha-1 collision if os.path.isfile(full_path) and not self._same_content(bin_data, full_path): raise UserError(_("The attachment collides with an existing file."))