Skip to content

Commit fbe6c69

Browse files
committed
Merge pull request #192 from RobberPhex/patch-1
修复大于4M的文件hash计算错误的问题
2 parents c7125a8 + 5740a0a commit fbe6c69

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

qiniu/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ def etag_stream(input_stream):
117117
输入流的etag值
118118
"""
119119
array = [_sha1(block) for block in _file_iter(input_stream, _BLOCK_SIZE)]
120+
if len(array) == 0:
121+
array = [_sha1(b'')]
120122
if len(array) == 1:
121123
data = array[0]
122-
prefix = b('\x16')
124+
prefix = b'\x16'
123125
else:
124126
sha1_str = b('').join(array)
125127
data = _sha1(sha1_str)
126-
prefix = b('\x96')
128+
prefix = b'\x96'
127129
return urlsafe_base64_encode(prefix + data)
128130

129131

0 commit comments

Comments
 (0)