From f09edcddf9ab81bf71c82e5495e989b9ad8a1101 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 22 Feb 2016 15:31:06 +0100 Subject: [PATCH] [FIX] assets: empty compiled assets handling tl;dr: accept both `None` and empty ('') results as cache hits, then double-check that the file_size is really 0 A. Valid empty files When a LESS file compiles to an empty result (e.g. `variables.less`), do not treat the empty file as a cache miss. Those are valid because file_size == 0. Note: empty files are not stored in the attachment filestore and return a null (None) `datas` when read from the database. B. Invalid empty files Under some circumstances (e.g. damaged filestore, race conditions during deletion, etc.), cached compiled assets may be deleted in the underlying attachment filestore, while still present in the table. The filestore implementation returns an empty file ('') when they are later accessed. Those can be considered **invalid** because the expected file_size is > 0. --- openerp/addons/base/ir/ir_qweb.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 3533f21702e..e3114470c24 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -1351,7 +1351,9 @@ class AssetsBundle(object): outdated = True break if asset._content is None: - asset._content = ira_record.datas and ira_record.datas.decode('base64').decode('utf8') + asset._content = ira_record.datas and ira_record.datas.decode('base64').decode('utf8') or '' + if not asset._content and ira_record.file_size > 0: + asset._content = None # file missing, force recompile if any(asset._content is None for asset in assets.itervalues()): outdated = True