ome / omero-web

Django-based OMERO.web client
https://www.openmicroscopy.org/omero
17 stars 31 forks source link

Infinite loop when downloading tables with <10 rows. #593

Closed MicheleBortol closed 3 days ago

MicheleBortol commented 2 weeks ago

Bug

Trying to download an omero table with < 10 rows with the "Whole Table" download button (top right) causes an infinite loop and a wrong and always increasing download size (here 3MB for a real total size of ~ 79.59 KB ) to be displayed: image

The "Show current page as: CSV | JSON" links seem be work correctly.

To Reproduce

Open any table with less than 10 rows in omero web and click the "Whole Table" download button (top right). image

Quick examples at:

With rows >= 10 everything works:

Cause and fix?

In omero_table.html in the download_csv function in this line the batchSize evaluates to 0 for values of rowCount < 10. Then, when count is incremented here, since batchSize is 0 the count remains 0 causing the infinite loop.

I think this could be solved by forcing the batchSize to be at least 1 e.g. with: const batchSize = Math.min(Math.max(parseInt(rowCount/10), 1), MAX_BATCH_ROWS); If it is OK, I could open a PR with this change.

knabar commented 2 weeks ago

Thank you for investigating this, @MicheleBortol! I will work on a fix for the upcoming release.