Quote:
Originally Posted by BetterRed
Suggestion: an has_data function, analogue of has_cover.
|
Quote:
Originally Posted by ownedbycats
This is something I would use.
|
Such a function must query the file system, so it won't be fast. My suspicion is that you want to use this for column icons, which may make the performance unacceptable.
Implementation choices:
- Fastest would be to check if "data/" exists, regardless of whether or not there is anything in it. I suspect the false positive rate would be unacceptable.
- Next would be to check if "data/" contains anything.
- Equally performant as 2, or perhaps I should say non-performant, would be to permit checking if particular files exist by matching the list of files against a regular expression.
This python template does check #2. Make it a stored template and try it to see if it is sufficiently performant.
Code:
python:
def evaluate(book, context):
db = context.db.new_api
files = db.list_extra_files_matching(book.id)
return '1' if files else ''