inveniosoftware / invenio-s3

S3 file storage support for Invenio.
https://invenio-s3.readthedocs.io
MIT License
0 stars 16 forks source link

Number of parts are not correctly calculated #23

Closed egabancho closed 3 years ago

egabancho commented 3 years ago

Package version (if known): master

Describe the bug

When calculating the number of parts we use the default integer rounding

size // current_app.config['S3_MAXIMUM_NUMBER_OF_PARTS']

https://github.com/inveniosoftware/invenio-s3/blob/master/invenio_s3/storage.py#L26

Which can (and will) result in uploading a bigger number of parts than the maximum allowed number (max+1) when the floating part is smaller than .5 (3.1 will result in 3 rather than 4(

Expected behavior

The number of parts should never exceed S3_MAXIMUM_NUMBER_OF_PARTS