XX-net/XX-Net · warning
download size:%d, need size:%d, download fail.
Error message
download size:%d, need size:%d, download fail.
What it means
download_file() finished the HTTP read loop but the number of bytes written does not match the expected file size, so the download is considered incomplete/truncated; the partial file is deleted and the next mirror is tried.
Source
Thrown at code/default/launcher/download_modules.py:70
file_size = int(req.getheader(b'Content-Length', 0))
left = file_size
downloaded = 0
with open(filename, 'wb') as fp:
while True:
chunk_len = min(65536, left)
if not chunk_len:
break
chunk = req.read(chunk_len)
if not chunk:
break
fp.write(chunk)
downloaded += len(chunk)
left -= len(chunk)
if downloaded != file_size:
xlog.warn("download size:%d, need size:%d, download fail.", downloaded, file_size)
os.remove(filename)
continue
else:
if sha256 and sha256 != hash_file_sum(filename):
xlog.warn("donwload %s checksum fail.", filename)
return False
else:
xlog.info("download %s to %s success.", org_url, filename)
return True
except Exception as e:
xlog.exception("download %s to %s fail:%r", org_url, filename, e)
continue
xlog.warn("download %s fail", org_url)
def download_unzip(url, extract_path):
if os.path.isdir(extract_path):
return TrueView on GitHub (pinned to cfa5bc17b6)
Solutions
- Retry — the function already loops to the next URL/mirror; run the download again
- Check disk space: df -h in the download directory
- Use a different/more reliable download URL or download directly with a browser and place the file manually
- Disable or switch the proxy used for the download if transfers keep truncating
Defensive patterns
Strategy: retry
Validate before calling
import shutil, os
if shutil.disk_usage(download_dir).free < expected_size * 2:
raise RuntimeError('insufficient disk space for download') Prevention
- Retry downloads on size mismatch (the code already moves to the next URL)
- Verify disk space before large downloads
- Use stable mirrors and a reliable proxy for transfers
When it happens
Trigger: Server closes the connection early, proxy or GFW interference truncates the transfer, disk fills mid-write, or Content-Length mismatch — resulting in downloaded != file_size.
Common situations: Downloading XX-Net modules through an unstable proxy where the stream is cut off, a mirror serving truncated files, or insufficient disk space.
Related errors
- time out
- time out
- get README fail:
- download xxnet zip fail:
- download size:%d, need size:%d, download fail.
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/488b88e0965368c1.
Report an issue: GitHub.