Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e6e67c22d |
@@ -81,16 +81,23 @@ def main() -> None:
|
|||||||
|
|
||||||
def _upload(http: httpx.Client, release_id, path: Path) -> None:
|
def _upload(http: httpx.Client, release_id, path: Path) -> None:
|
||||||
data = path.read_bytes()
|
data = path.read_bytes()
|
||||||
uploaded = _post_asset(http, release_id, path.name, data)
|
uploaded = None
|
||||||
if uploaded.status_code != 413:
|
try:
|
||||||
if uploaded.status_code >= 300:
|
uploaded = _post_asset(http, release_id, path.name, data)
|
||||||
raise SystemExit(f"上传压缩包失败 {uploaded.status_code}")
|
except httpx.TransportError:
|
||||||
|
uploaded = None
|
||||||
|
if uploaded is not None and uploaded.status_code < 300:
|
||||||
return
|
return
|
||||||
|
if uploaded is not None and uploaded.status_code != 413:
|
||||||
|
raise SystemExit(f"上传压缩包失败 {uploaded.status_code}")
|
||||||
count = (len(data) + PART_SIZE - 1) // PART_SIZE
|
count = (len(data) + PART_SIZE - 1) // PART_SIZE
|
||||||
for index in range(count):
|
for index in range(count):
|
||||||
part = data[index * PART_SIZE : (index + 1) * PART_SIZE]
|
part = data[index * PART_SIZE : (index + 1) * PART_SIZE]
|
||||||
name = f"{path.name}.part{index + 1:03d}"
|
name = f"{path.name}.part{index + 1:03d}"
|
||||||
uploaded = _post_asset(http, release_id, name, part)
|
try:
|
||||||
|
uploaded = _post_asset(http, release_id, name, part)
|
||||||
|
except httpx.TransportError as exc:
|
||||||
|
raise SystemExit("上传压缩包时连接中断") from exc
|
||||||
if uploaded.status_code >= 300:
|
if uploaded.status_code >= 300:
|
||||||
raise SystemExit(f"上传压缩包失败 {uploaded.status_code}")
|
raise SystemExit(f"上传压缩包失败 {uploaded.status_code}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user