SenseNet / sensenet

Open Source Content Services Platform written in .NET
https://sensenet.com
GNU General Public License v2.0
173 stars 112 forks source link

Import: Unexpected behavior with preview switched OFF in the CTD #1934

Closed VargaJoe closed 7 months ago

VargaJoe commented 1 year ago

Based on my understanding, the <Preview>false</Preview> setting in the Content Type Definition (CTD) should disable preview generation for the specific content type. However, it appears that the functionality is still being triggered. (Edit: not during import, but after that, on admin UI)

In some cases, the "Generate" button is displayed on the preview page for certain files. For other files, the message "Preview generation is in progress" is shown, while in some cases, the preview image is loaded immediately. I experienced the mentioned issue specifically with contents in JPG and PNG formats.

Taskmanager version is from 2022 november. Snaas repository is from the latest release.

Investigation

There are two switches:

Both the CTD and the local switch on the container work correctly during import. This means that even if an imported item has a content file with a real PageCount value (e.g. 1), preview generation will NOT start if any of the switches is set to False/No.

If preview is enabled on the content type but switched off on the parent (this is considered a temporary switch to speed up importing) the PageCount value will be set to PostPoned (-4) during import. This is OK, because we will have to regenerate the images later.

BUG1: On admin ui: pressing the Generate button sets the PageCount value to "Generating" even if preview is not enabled locally on the parent. In this case we should keep the state as Posponed.

See code here: https://github.com/SenseNet/sensenet/blob/27500e81b48f97e7494a887b39fea9064e872547/src/ContentRepository/Preview/DocumentPreviewProvider.cs#L1805

VargaJoe commented 1 year ago

It appears that the inconsistency may be caused by the settings of the previously exported content. It is possible that the specific image already had a preview associated with it in the earlier sensenet repository. As a result, the Content Type Definition (CTD) configuration is not being taken into account, leading to an attempt to regenerate the preview unnecessarily.