Revision 6e50fed4

b/kamaki/clients/pithos/__init__.py
54 54

  
55 55
def _range_up(start, end, a_range):
56 56
    if a_range:
57
        (rstart, rend) = a_range.split('-')
58
        (rstart, rend) = (int(rstart), int(rend))
57
        rstart, sep, rend = a_range.partition('-')
58
        if rstart:
59
            if sep:
60
                rstart, rend = int(rstart), int(rend)
61
            else:
62
                rstart, rend = 0, int(rstart)
63
        elif sep:
64
            return (0, - int(rend))
65
        else:
66
            return (0, 0)
59 67
        if rstart > end or rend < start:
60 68
            return (0, 0)
61 69
        if rstart > start:
......
634 642
                is_last = start + blocksize > total_size
635 643
                end = (total_size - 1) if is_last else (start + blocksize - 1)
636 644
                (start, end) = _range_up(start, end, crange)
637
                args['data_range'] = 'bytes=%s-%s' % (start, end)
645
                args['data_range'] = 'bytes=%s-%s' % (
646
                    (start, end) if end >= 0 else ('', - end))
638 647
                r = self.object_get(obj, success=(200, 206), **args)
639 648
                self._cb_next()
640 649
                dst.write(r.content)
......
704 713
                    self._cb_next()
705 714
                    continue
706 715
                restargs['async_headers'] = {
707
                    'Range': 'bytes=%s-%s' % (start, end)}
716
                    'Range': 'bytes=%s-%s' % (
717
                        (start, end) if end >= 0 else ('', - end))}
708 718
                flying[key] = self._get_block_async(obj, **restargs)
709 719
                blockid_dict[key] = unsaved
710 720

  
......
848 858
                is_last = start + blocksize > total_size
849 859
                end = (total_size - 1) if is_last else (start + blocksize - 1)
850 860
                (start, end) = _range_up(start, end, range_str)
851
                if start < end:
861
                if start < end or end < 0:
852 862
                    self._watch_thread_limit(flying.values())
853 863
                    flying[blockid] = self._get_block_async(obj, **restargs)
854 864
                for runid, thread in flying.items():

Also available in: Unified diff