[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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user