Skip to content

The createLargeObject() does not work correctly for segment count 10 and more #365

Description

@vpecinka

In the method createLargeObject() there is on this line the following construct

'name'          => sprintf('%s/%d', $segmentPrefix, ++$count),

however, when there is more than 9 parts (segments) the resulting large file will not be restored correctly, as the Swift object storage orders the segments by filename...

As stated here in Swift docs: All the object segments need to be in the same container, have a common object name prefix, and sort in the order in which they should be concatenated. Object names are sorted lexicographically as UTF-8 byte strings.

The current code produces something like this

segmentPrefix/1
segmentPrefix/10
segmentPrefix/11
segmentPrefix/2
segmentPrefix/3

and should produce

segmentPrefix/0001
segmentPrefix/0002
segmentPrefix/0003
:
:
segmentPrefix/0010
segmentPrefix/0011

therefore I suggest to change the code to this:

'name'          => sprintf('%s/%05d', $segmentPrefix, ++$count),

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions