php-opencloud / openstack

PHP SDK for OpenStack clouds
Apache License 2.0
221 stars 148 forks source link

format segment name, close #365 #366

Closed vpecinka closed 1 year ago

vpecinka commented 1 year ago

For Swift storage and large objects numbers has to be padded with zero for correct segment order.

k0ka commented 1 year ago

Thank you for the PR.

Your current implementation has not obvious limit of 10000 segments. I guess we should either assert it and throw an exception or add another parameter $data['segmentCountFormat'] to createLargeObject with default value %05d.

I also want to add an integration test for this case.

vpecinka commented 1 year ago

added the config option segmentIndexFormat with default value %05d and fixed the unit test.

vpecinka commented 1 year ago

also added isValidSegmentIndexFormat() to check proper format (has to produce different values for given format and different values, plus result has to have same string length)