Comment 0 for bug 1075184

Revision history for this message
david (w-david-cole) wrote :

bin/swift in python-swiftclient.

If you specific the segment size to be X, files smaller than X should NOT be put into the _segment container and be created in the main container as manifest files. Currently the do due to the following :

    if options.segment_size and \
            getsize(path) < options.segment_size:

two problems to my eyes - the comparison is wrong (should be greater than) and we're comparing with a string. The fix would be:

    if options.segment_size and \
            getsize(path) > int(options.segment_size):

>>> bigfile = '/path/to/file/bigger/than/1gig'
>>> smallfile = '/etc/hosts'

>>> segment_size = '1073741824'
>>> segment_size and os.path.getsize(bigfile) < segment_size
True
>>> segment_size and os.path.getsize(smallfile) < segment_size
True

>>> segment_size and os.path.getsize(bigfile) > segment_size
False
>>> segment_size and os.path.getsize(smallfile) > segment_size
False

>>> segment_size and os.path.getsize(smallfile) > int(segment_size)
False
>>> segment_size and os.path.getsize(bigfile) > int(segment_size)
True