{"record":{"id":"42a761ab3f6ef2ff","repo":"XX-net/XX-Net","slug":"download-size-d-need-size-d-download-fail-42a761","errorCode":null,"errorMessage":"download size:%d, need size:%d, download fail.","messagePattern":"download size:(.+?), need size:(.+?), download fail\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/launcher/update_from_github.py","lineNumber":146,"sourceCode":"\n                left = file_size\n                downloaded = 0\n                with open(filename, 'wb') as fp:\n                    while global_var.running:\n                        chunk_len = min(65536, left)\n                        if not chunk_len:\n                            break\n\n                        chunk = req.read(chunk_len)\n                        if not chunk:\n                            break\n                        fp.write(chunk)\n                        downloaded += len(chunk)\n                        progress[url][\"downloaded\"] = downloaded\n                        left -= len(chunk)\n\n            if downloaded != progress[url][\"size\"]:\n                xlog.warn(\"download size:%d, need size:%d, download fail.\", downloaded, progress[url][\"size\"])\n                continue\n            else:\n                progress[url][\"status\"] = \"finished\"\n                return True\n        except Exception as e:\n            xlog.exception(\"download %s to %s fail:%r\", url, filename, e)\n            continue\n\n    progress[url][\"status\"] = \"failed\"\n    return False\n\n\ndef parse_update_versions(readme_file):\n    versions = []\n    try:\n        fd = open(readme_file, \"rb\")\n        lines = fd.readlines()\n        p = re.compile(br'https://codeload.github.com/XX-net/XX-Net/zip/([0-9]+)\\.([0-9]+)\\.([0-9]+) ([0-9a-fA-F]*)')","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/launcher/update_from_github.py#L128-L164","documentation":"Logged when a chunked HTTP download finishes but the total bytes written do not equal the Content-Length recorded for that URL. The downloader loops URLs and continues to the next candidate, so this is a size-mismatch failure of one mirror, not necessarily a total failure.","triggerScenarios":"download_file() completes its read loop (or breaks early on a short stream) and downloaded != progress[url]['size']; typical with truncated responses from GitHub/raw.githubusercontent mirrors, proxies closing early, or a redirect page returned instead of the binary.","commonSituations":"Updating XX-Net behind an unstable proxy or firewall where GitHub responses are cut off; a mirror returning an HTML error page with a different Content-Length; disk full mid-write.","solutions":["Check network/proxy stability and retry the update (the loop already tries the next URL).","Verify the URL list in get_github_versions() is reachable with curl -I and compare Content-Length.","If a specific mirror is persistently bad, remove/replace that URL in the version metadata.","Ensure disk space on the download path."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// treat download_file as fallible; it already rotates URLs\nif not download_file(url_list, filename):\n    raise UpdateDownloadError('all mirrors failed for %s' % filename)","preventionTips":["Monitor progress[url]['status'] instead of assuming success.","Run updates on a stable network path.","Pre-check disk space before update."],"tags":["network","download","size-mismatch","update"],"backgroundTag":"download-truncated","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}