Skip to content
Snippets Groups Projects
Commit fbfae7ef authored by Xavier-Do's avatar Xavier-Do Committed by fw-bot
Browse files

[IMP] base: avoid invalidate cache on first assets


Assets bundle creation will try to find previous version of assets and unlink them.
This needs to invalidate ormcache to notify other workers.

Since assets are never commited during test, assets will be generate at each request if request is
not commited (cursor closed) whtch is the case with 404.

Invalidating the orm cache only when a previous attachement was existing will help to
mitigate the problem, and slightly improve HTTPCases test speed.

closes odoo/odoo#38979

X-original-commit: d4d63549
Signed-off-by: default avatarXavier Dollé (xdo) <xdo@odoo.com>
parent d65fcfec
No related branches found
No related tags found
No related merge requests found
......@@ -230,11 +230,15 @@ class AssetsBundle(object):
('url', '=like', url),
'!', ('url', '=like', self.get_asset_url(unique=self.version))
]
attachments = ira.sudo().search(domain)
# avoid to invalidate cache if it's already empty (mainly useful for test)
# force bundle invalidation on other workers
self.env['ir.qweb'].clear_caches()
if attachments:
attachments.unlink()
# force bundle invalidation on other workers
self.env['ir.qweb'].clear_caches()
return ira.sudo().search(domain).unlink()
return True
def get_attachments(self, type, ignore_version=False):
""" Return the ir.attachment records for a given bundle. This method takes care of mitigating
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment