mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
优化download()获取文件大小逻辑
This commit is contained in:
parent
265c997efc
commit
7ae5ec6541
@ -324,7 +324,8 @@ class SessionPage(object):
|
|||||||
|
|
||||||
# -------------------开始下载-------------------
|
# -------------------开始下载-------------------
|
||||||
# 获取远程文件大小
|
# 获取远程文件大小
|
||||||
file_size = int(r.headers['Content-Length']) if 'Content-Length' in r.headers else None
|
content_length = tuple(x for x in r.headers if x.lower() == 'content-length')
|
||||||
|
file_size = int(r.headers[content_length]) if content_length else None
|
||||||
downloaded_size, download_status = 0, False # 已下载文件大小和下载状态
|
downloaded_size, download_status = 0, False # 已下载文件大小和下载状态
|
||||||
try:
|
try:
|
||||||
with open(str(full_path), 'wb') as tmpFile:
|
with open(str(full_path), 'wb') as tmpFile:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user