Closed lebouquetin closed 3 years ago
Here is the diff between 0.13 and 0.14 versions: https://github.com/algoo/preview-generator/compare/release_0.13...release_0.14
Note: I'd be happy you ask me about the old behavior if you need to investiguate old stuff (which is not always easy to understand)
We add a talk with @inkhey about architecture ... then I realized the issue was not there.
Actually, since 2020-07-03 the process of building the pivot pdf file is implemented in the manager.
The process in manager Manager.get_jpeg_preview()
is:
The resolution is to change the second builder used:
with preview_context.filelock:
if force or not os.path.exists(preview_file_path):
preview_context.builder.build_jpeg_preview(
file_path=file_path,
preview_name=preview_name,
cache_path=self.cache_path,
page_id=max(page, 0), # if page is -1 then return preview of first page,
extension=extension,
size=size,
mimetype=preview_context.mimetype,
)
should become:
preview_context2 = self.get_preview_context(file_path, file_ext) # now file_path is the PDF pivot file path
with preview_context.filelock:
if force or not os.path.exists(preview_file_path):
preview_context2.builder.build_jpeg_preview(
file_path=file_path,
preview_name=preview_name,
cache_path=self.cache_path,
page_id=max(page, 0), # if page is -1 then return preview of first page,
extension=extension,
size=size,
mimetype=preview_context.mimetype,
)
This fixes the performance issue.
By the way, there are two other fixes to implement:
cc @grignards
@lebouquetin in current code, i don't see any reason to implement two-step process for other preview methods, text_preview and json make sense to be generated from default content (and are now) but i agree that we should verify this kind of things, for example, It will make sense for a "png builder" that doesn't exist yet
As discussed at the moment:
get_page_nb()
process should be similar to get_jpeg_preview()
- not use a pivot PDF file but raise an exception "convert the document to PDF firstSo, remaining work is:
get_page_nb()
featurerelease 0.18 MUST be ready in order to close https://github.com/tracim/tracim/issues/4587
With preview-generator 0.13, the mechanism for an office preview process is:
Starting with preview-generator 0.14, the process is very slow. In last version, libreoffice is executed for every page preview, even if the pviot PDF file is available
How to reproduce:
Also add a debug output before to execute libreoffice: