{"record":{"id":"48d88fafdb5378c8","repo":"deezer/spleeter","slug":"downloaded-file-is-corrupted-please-retry","errorCode":null,"errorMessage":"Downloaded file is corrupted, please retry","messagePattern":"Downloaded file is corrupted, please retry","errorType":"exception","errorClass":"IOError","httpStatus":null,"severity":"error","filePath":"spleeter/model/provider/github.py","lineNumber":157,"sourceCode":"                Path of the directory to save model into.\n        \"\"\"\n        url: str = \"/\".join(\n            (self._host, self._repository, self.RELEASE_PATH, self._release, name)\n        )\n        url = f\"{url}.tar.gz\"\n        logger.info(f\"Downloading model archive {url}\")\n        with httpx.Client(http2=True) as client:\n            with client.stream(\"GET\", url) as response:\n                response.raise_for_status()\n                archive = NamedTemporaryFile(delete=False)\n                try:\n                    with archive as stream:\n                        for chunk in response.iter_raw():\n                            stream.write(chunk)\n                    logger.info(\"Validating archive checksum\")\n                    checksum: str = compute_file_checksum(archive.name)\n                    if checksum != self.checksum(name):\n                        raise IOError(\"Downloaded file is corrupted, please retry\")\n                    logger.info(f\"Extracting downloaded {name} archive\")\n                    with tarfile.open(name=archive.name) as tar:\n                        tar.extractall(path=path)\n                finally:\n                    os.unlink(archive.name)\n        logger.info(f\"{name} model file(s) extracted\")\n","sourceCodeStart":139,"sourceCodeEnd":164,"githubUrl":"https://github.com/deezer/spleeter/blob/c8854001ac8acad34a9bc2bd15f28475541828b1/spleeter/model/provider/github.py#L139-L164","documentation":"After downloading a model archive, download() computes the file's SHA checksum and compares it to the expected checksum from the remote index; a mismatch raises IOError. It means the transfer produced bytes that do not match what the publisher recorded, so the archive is not trusted and is not extracted. This is a deliberate integrity guard against truncated or tampered downloads.","triggerScenarios":"Calling download(name, path) when the HTTP transfer is truncated (dropped connection mid iter_raw), a proxy/mirror serves a modified archive, or the remote archive was updated without updating the checksum index (or vice versa).","commonSituations":"Flaky Wi-Fi or CI network interrupting large model downloads; corporate proxies or CDN caches serving stale artifacts; spleeter version mismatch where the archive at the URL was replaced but the index still holds the old checksum; disk-full conditions silently shortening the written file.","solutions":["Simply retry the download — transient truncation is the most common cause","Clear any proxy/CDN cache or disable a middle-box that may serve a stale archive, then retry","Confirm disk space is sufficient for the archive before downloading","If it persists, check that your spleeter version's model URL and checksum index are in sync; upgrade spleeter or pin a release where archive and checksum match"],"exampleFix":"// before\nseparator = Separator('spleeter:2stems')  # flaky network -> IOError corrupted\n// after\nimport time\nfor attempt in range(3):\n    try:\n        separator = Separator('spleeter:2stems')\n        break\n    except IOError as e:\n        if 'corrupted' not in str(e) or attempt == 2:\n            raise\n        time.sleep(2)","handlingStrategy":"retry","validationCode":"import os\n\nassert os.path.getfreebytes(path if hasattr(os.path, 'getfreebytes') else '.') > 500 * 1024 * 1024  # ensure disk space for the archive","typeGuard":"import hashlib\n\ndef sha256_matches(file_path: str, expected: str) -> bool:\n    h = hashlib.sha256()\n    with open(file_path, 'rb') as f:\n        for chunk in iter(lambda: f.read(1 << 20), b''):\n            h.update(chunk)\n    return h.hexdigest() == expected","tryCatchPattern":"for attempt in range(3):\n    try:\n        provider.download(name, path)\n        break\n    except IOError as e:\n        if 'corrupted' not in str(e):\n            raise\n        if attempt == 2:\n            raise RuntimeError('Model download corrupted after 3 attempts; check network/proxy') from e","preventionTips":["Retry downloads on stable networks; avoid flaky Wi-Fi for multi-hundred-MB archives","Bypass or reconfigure proxies/CDNs that may cache stale model artifacts","Check free disk space before downloading","Keep spleeter and its model index URL in sync (upgrade together)"],"tags":["download","checksum","ioerror","integrity","network"],"backgroundTag":"downloaded-file-corrupted","analyzedSha":"c8854001ac8acad34a9bc2bd15f28475541828b1","analyzedAt":"2026-08-28T21:38:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}