Skip to content

Commit

Permalink
Merge pull request #131 from jayzhenghan/master
Browse files Browse the repository at this point in the history
修复断点续传下载的bug
  • Loading branch information
dt3310321 authored Aug 14, 2020
2 parents a8da9b9 + 9b1dadc commit 9366d37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,7 @@ def download_file(self, Bucket, Key, DestFilePath, PartSize=20, MAZThread=5, Ena
max_thread: {4}".format(Bucket, Key, DestFilePath, PartSize, MAZThread))

object_info = self.head_object(Bucket, Key)
file_size = object_info['Content-Length']
file_size = int(object_info['Content-Length'])
if file_size <= 1024*1024*20:
response = self.get_object(Bucket, Key, **Kwargs)
response['Body'].get_stream_to_file(DestFilePath)
Expand Down
6 changes: 3 additions & 3 deletions qcloud_cos/resumable_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def start(self):
logger.debug('download success, bucket: {0}, key: {1}'.format(self.__bucket, self.__key))

def __get_record_filename(self, bucket, key, dest_file_path):
dest_file_path_md5 = hashlib.md5(dest_file_path).hexdigest()
key_md5 = hashlib.md5(key).hexdigest()
dest_file_path_md5 = hashlib.md5(dest_file_path.encode("utf-8")).hexdigest()
key_md5 = hashlib.md5(key.encode("utf-8")).hexdigest()
return '{0}_{1}.{2}'.format(bucket, key_md5, dest_file_path_md5)

def __determine_part_size_internal(self, file_size, part_size):
Expand All @@ -90,7 +90,7 @@ def __determine_part_size_internal(self, file_size, part_size):
def __splite_to_parts(self):
parts = []
file_size = int(self.__object_info['Content-Length'])
num_parts = (file_size + self.__part_size - 1) / self.__part_size
num_parts = int((file_size + self.__part_size - 1) / self.__part_size)
for i in range(num_parts):
start = i * self.__part_size
if i == num_parts - 1:
Expand Down

0 comments on commit 9366d37

Please sign in to comment.