Files smaller than --segment-size not handled correctly.

Bug #1075184 reported by david
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-swiftclient
Fix Released
Undecided
Zhou Yuan

Bug Description

bin/swift in python-swiftclient.

If you specify the segment size to be X, files smaller than X should NOT be put into the _segment container and should not be created in the main container as manifest files. Currently they 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(bigfile) > int(segment_size)
True
>>> segment_size and os.path.getsize(smallfile) > int(segment_size)
False

david (w-david-cole)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-swiftclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/16879

Changed in python-swiftclient:
assignee: nobody → Zhou Yuan (yuan-zhou)
status: New → In Progress
Changed in python-swiftclient:
status: In Progress → Fix Committed
Changed in python-swiftclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.