Bug in thumbnail generation

Dear all,

I would like to report a bug in the Seafile thumbnail generation. I am using the latest server version 6.0.7 for RPI on an Odroid XU4 board, deployed on nginx with FastCGI.

I am using Seafile mainly as an image server. When I open a folder with many pictures then sometimes broken thumbnails are generated, i.e. the thumbnail files are generated but are not valid image files, resulting in blank thumbnails that are also not corrected on reloading of the page.

It took me some time to find the cause of the problem, but it seems that if not all thumbs are generated yet and if one scrolls down the page, such that more pictures than the first 100 are loaded, the python function to load thumbnails is called a second time, after 200 pics a third time and so on.

If the thumbnails already exist then this is not a problem, but if they are generated then the multiple processes sometimes write to the same files, at the same time, resulting in broken thumbnails. This happens more often in the larger thumbnail mode, I guess because the image save operation takes longer, making an overlap more likely.

I think a rather easy fix to this problem would be to call the getImageThumbnail function at the first time not on all pictures, but only on the first 100 and on scrolling also not on all pictures, but only on the next 100, and so on.

Besides, I would like to make a feature request:

Right now the ajax call for getting thumbnails is happening synchronously in a recursive manner, i.e. one thumb after the other, which results in only a single python process to load or generate the thumbnails. On platforms like the XU4 with multiple, slow cores this creates a performance bottleneck.

To my opinion, it would be a much better solution to make the ajax call asynchronous (async:true) and iterative instead of recursive, which would enable parallelism in the thumbnail loading and generation process (multiple python processes working on different files), from which multi-core platforms should gain a substantial performance benefit.

Please give me your thoughts on this bug and the feature request. Thanks in advance.

Best regards,
pi-xel