Skip to content

Commit

Permalink
Merge pull request qiniu#192 from RobberPhex/patch-1
Browse files Browse the repository at this point in the history
修复大于4M的文件hash计算错误的问题
  • Loading branch information
longbai committed Apr 30, 2016
2 parents c7125a8 + 5740a0a commit fbe6c69
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qiniu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ def etag_stream(input_stream):
输入流的etag值
"""
array = [_sha1(block) for block in _file_iter(input_stream, _BLOCK_SIZE)]
if len(array) == 0:
array = [_sha1(b'')]
if len(array) == 1:
data = array[0]
prefix = b('\x16')
prefix = b'\x16'
else:
sha1_str = b('').join(array)
data = _sha1(sha1_str)
prefix = b('\x96')
prefix = b'\x96'
return urlsafe_base64_encode(prefix + data)


Expand Down

0 comments on commit fbe6c69

Please sign in to comment.