Commit f17121cd authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Do not recalculate #blocks in upload_from_string

Refs: #3608
parent f7a37648
...@@ -520,12 +520,9 @@ class PithosClient(PithosRestClient): ...@@ -520,12 +520,9 @@ class PithosClient(PithosRestClient):
if not content_type: if not content_type:
content_type = 'application/octet-stream' content_type = 'application/octet-stream'
num_of_blocks, blockmod = size / blocksize, size % blocksize
num_of_blocks += (1 if blockmod else 0) if num_of_blocks else blockmod
hashes = [] hashes = []
hmap = {} hmap = {}
for blockid in range(num_of_blocks): for blockid in range(nblocks):
start = blockid * blocksize start = blockid * blocksize
block = input_str[start: (start + blocksize)] block = input_str[start: (start + blocksize)]
hashes.append(_pithos_hash(block, blockhash)) hashes.append(_pithos_hash(block, blockhash))
...@@ -547,8 +544,8 @@ class PithosClient(PithosRestClient): ...@@ -547,8 +544,8 @@ class PithosClient(PithosRestClient):
num_of_missing = len(missing) num_of_missing = len(missing)
if upload_cb: if upload_cb:
self.progress_bar_gen = upload_cb(num_of_blocks) self.progress_bar_gen = upload_cb(nblocks)
for i in range(num_of_blocks + 1 - num_of_missing): for i in range(nblocks + 1 - num_of_missing):
self._cb_next() self._cb_next()
tries = 7 tries = 7
......
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