File tree Expand file tree Collapse file tree 4 files changed +7
-11
lines changed
Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ def get_hash_content(org, content: io.BytesIO):
257257 h = hashlib .md5 ()
258258 else :
259259 h = hashlib .sha1 ()
260- h .update (content )
260+ h .update (content . getbuffer () )
261261 return org == h .hexdigest ()
262262
263263
Original file line number Diff line number Diff line change 1919def _load_cert (cert , key ):
2020 global server_side_ssl , client_side_ssl , _loaded
2121 if not os .path .exists (cert ) or not os .path .exists (key ):
22- logger .terror ("cert.error.failed.file" , cert = cert , key = key )
22+ logger .terror ("cert.error.failed.file" , cert = cert , path = key )
2323 return False
2424 try :
2525 server_side_ssl .load_cert_chain (cert , key )
Original file line number Diff line number Diff line change @@ -402,14 +402,14 @@ async def __call__(
402402 self .start_task ()
403403 return
404404 with tqdm (
405+ desc = locale .t ("cluster.tqdm.desc.check_files" ),
405406 total = len (files ) * len (storages .get_storages ()),
406407 unit = locale .t ("cluster.tqdm.unit.file" ),
407408 unit_scale = True ,
408409 ) as pbar :
409410 self .pbar = pbar
410411 self .files = files
411412 await dashboard .set_status_by_tqdm ("files.checking" , pbar )
412- pbar .set_description (locale .t ("cluster.tqdm.desc.check_files" ))
413413 try :
414414 miss_storage : list [list [BMCLAPIFile ]] = await asyncio .gather (
415415 * [
Original file line number Diff line number Diff line change 1919import zlib
2020from core .exceptions import (
2121 WebSocketError ,
22- ServerWebSocketError ,
2322 ServerWebSocketUnknownDataError ,
2423)
2524from typing import (
@@ -906,13 +905,10 @@ async def __call__(
906905 client .write (content .getbuffer ()[start_bytes : end_bytes + 1 ])
907906 await client .drain ()
908907 elif isinstance (content , Path ):
909- async with aiofiles .open (content , "rb" ) as r :
910- cur_length : int = 0
911- await r .seek (start_bytes , os .SEEK_SET )
912- while data := await r .read (max (0 , min (IO_BUFFER , length - cur_length ))):
913- cur_length += len (data )
914- client .write (data )
915- await client .drain ()
908+ with open (content , "rb" ) as r :
909+ await asyncio .get_event_loop ().sendfile (
910+ client .writer .transport , r , start_bytes , length
911+ )
916912 else :
917913 cur_length : int = 0
918914 bound : bool = False
You can’t perform that action at this time.
0 commit comments