Commit 91d443f9 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Fix bug w. 0 file syncing

parent 1e92e97d
...@@ -66,9 +66,11 @@ def _range_up(start, end, max_value, a_range): ...@@ -66,9 +66,11 @@ def _range_up(start, end, max_value, a_range):
:returns: (str) a range string cut-off for the start-end range :returns: (str) a range string cut-off for the start-end range
an empty response means this window is out of range an empty response means this window is out of range
""" """
assert start >= 0, '_range_up was called with start < 0' assert start >= 0, '_range_up called w. start(%s) < 0' % start
assert end >= start, '_range_up was called with end < start' assert end >= start, '_range_up called w. end(%s) < start(%s)' % (
assert end <= max_value, '_range_up was called with max_value < end' end, start)
assert end <= max_value, '_range_up called w. max_value(%s) < end(%s)' % (
max_value, end)
if not a_range: if not a_range:
return '%s-%s' % (start, end) return '%s-%s' % (start, end)
selected = [] selected = []
...@@ -727,19 +729,21 @@ class PithosClient(PithosRestClient): ...@@ -727,19 +729,21 @@ class PithosClient(PithosRestClient):
self._cb_next(len(blockids) - len(unsaved)) self._cb_next(len(blockids) - len(unsaved))
if unsaved: if unsaved:
key = unsaved[0] key = unsaved[0]
self._watch_thread_limit(flying.values()) if key:
self._thread2file( self._watch_thread_limit(flying.values())
flying, blockid_dict, local_file, offset, self._thread2file(
**restargs) flying, blockid_dict, local_file, offset,
end = total_size - 1 if ( **restargs)
key + blocksize > total_size) else key + blocksize - 1 end = total_size - 1 if (
data_range = _range_up(key, end, total_size, filerange) key + blocksize > total_size) else key + blocksize - 1
if not data_range: data_range = _range_up(key, end, total_size, filerange)
self._cb_next() if not data_range:
continue self._cb_next()
restargs['async_headers'] = {'Range': 'bytes=%s' % data_range} continue
flying[key] = self._get_block_async(obj, **restargs) restargs[
blockid_dict[key] = unsaved 'async_headers'] = {'Range': 'bytes=%s' % data_range}
flying[key] = self._get_block_async(obj, **restargs)
blockid_dict[key] = unsaved
for thread in flying.values(): for thread in flying.values():
thread.join() thread.join()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment