mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
refactoring
This commit is contained in:
parent
9aa3998924
commit
da2e86ae72
@ -123,7 +123,7 @@ class MsdApi:
|
||||
name = htclient.get_filename(remote)
|
||||
name = valid_msd_image_name(name)
|
||||
|
||||
size = htclient.get_content_length(remote)
|
||||
size = valid_int_f0(remote.content_length)
|
||||
|
||||
get_logger(0).info("Downloading image %r as %r to MSD ...", url, name)
|
||||
async with self.__msd.write_image(name, size) as chunk_size:
|
||||
|
||||
@ -51,16 +51,6 @@ def raise_not_200(response: aiohttp.ClientResponse) -> None:
|
||||
)
|
||||
|
||||
|
||||
def get_content_length(response: aiohttp.ClientResponse) -> int:
|
||||
try:
|
||||
value = int(response.headers["Content-Length"])
|
||||
except Exception:
|
||||
raise aiohttp.ClientError("Empty or invalid Content-Length")
|
||||
if value < 0:
|
||||
raise aiohttp.ClientError("Negative Content-Length")
|
||||
return value
|
||||
|
||||
|
||||
def get_filename(response: aiohttp.ClientResponse) -> str:
|
||||
try:
|
||||
disp = response.headers["Content-Disposition"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user