{"record":{"id":"7b3011c5fe8307a9","repo":"HelloZeroNet/ZeroNet","slug":"file-size-does-not-match-sb-sb","errorCode":null,"errorMessage":"File size does not match: %sB != %sB","messagePattern":"File size does not match: (.+?)B != (.+?)B","errorType":"exception","errorClass":"RequestError","httpStatus":null,"severity":"error","filePath":"src/File/FileRequest.py","lineNumber":234,"sourceCode":"        try:\n            file_path = site.storage.getPath(params[\"inner_path\"])\n            if streaming:\n                file_obj = site.storage.open(params[\"inner_path\"])\n            else:\n                file_obj = Msgpack.FilePart(file_path, \"rb\")\n\n            with file_obj as file:\n                file.seek(params[\"location\"])\n                read_bytes = params.get(\"read_bytes\", FILE_BUFF)\n                file_size = os.fstat(file.fileno()).st_size\n\n                if file_size > read_bytes:  # Check if file is readable at current position (for big files)\n                    if not self.isReadable(site, params[\"inner_path\"], file, params[\"location\"]):\n                        raise RequestError(\"File not readable at position: %s\" % params[\"location\"])\n                else:\n                    if params.get(\"file_size\") and params[\"file_size\"] != file_size:\n                        self.connection.badAction(2)\n                        raise RequestError(\"File size does not match: %sB != %sB\" % (params[\"file_size\"], file_size))\n\n                if not streaming:\n                    file.read_bytes = read_bytes\n\n                if params[\"location\"] > file_size:\n                    self.connection.badAction(5)\n                    raise RequestError(\"Bad file location\")\n\n                if streaming:\n                    back = {\n                        \"size\": file_size,\n                        \"location\": min(file.tell() + read_bytes, file_size),\n                        \"stream_bytes\": min(read_bytes, file_size - params[\"location\"])\n                    }\n                    self.response(back)\n                    self.sendRawfile(file, read_bytes=read_bytes)\n                else:\n                    back = {","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/HelloZeroNet/ZeroNet/blob/454c0b2e7e000fda7000cba49027541fbf327b96/src/File/FileRequest.py#L216-L252","documentation":"Integrity check in handleGetFile: the client-supplied params['file_size'] does not match the actual on-disk size (os.fstat) of the requested file. The input at fault is a stale file_size from the peer, indicating the client's manifest is outdated or the file changed mid-transfer.","triggerScenarios":"Thrown at src/File/FileRequest.py:234 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Client should re-fetch the latest content.json and update its known file_size, then retry","Verify the site content (siteVerify) to reconcile local size with the signed manifest","Catch the error in the request handler and reply with an error dict rather than sending mismatched data"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"454c0b2e7e000fda7000cba49027541fbf327b96","analyzedAt":"2026-09-02T19:46:57.278Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}