HelloZeroNet/ZeroNet · error · RequestError

File size does not match: %sB != %sB

Error message

File size does not match: %sB != %sB

What it means

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.

Source

Thrown at src/File/FileRequest.py:234

        try:
            file_path = site.storage.getPath(params["inner_path"])
            if streaming:
                file_obj = site.storage.open(params["inner_path"])
            else:
                file_obj = Msgpack.FilePart(file_path, "rb")

            with file_obj as file:
                file.seek(params["location"])
                read_bytes = params.get("read_bytes", FILE_BUFF)
                file_size = os.fstat(file.fileno()).st_size

                if file_size > read_bytes:  # Check if file is readable at current position (for big files)
                    if not self.isReadable(site, params["inner_path"], file, params["location"]):
                        raise RequestError("File not readable at position: %s" % params["location"])
                else:
                    if params.get("file_size") and params["file_size"] != file_size:
                        self.connection.badAction(2)
                        raise RequestError("File size does not match: %sB != %sB" % (params["file_size"], file_size))

                if not streaming:
                    file.read_bytes = read_bytes

                if params["location"] > file_size:
                    self.connection.badAction(5)
                    raise RequestError("Bad file location")

                if streaming:
                    back = {
                        "size": file_size,
                        "location": min(file.tell() + read_bytes, file_size),
                        "stream_bytes": min(read_bytes, file_size - params["location"])
                    }
                    self.response(back)
                    self.sendRawfile(file, read_bytes=read_bytes)
                else:
                    back = {

View on GitHub (pinned to 454c0b2e7e)

Solutions

  1. Client should re-fetch the latest content.json and update its known file_size, then retry
  2. Verify the site content (siteVerify) to reconcile local size with the signed manifest
  3. Catch the error in the request handler and reply with an error dict rather than sending mismatched data
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/File/FileRequest.py:234 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HelloZeroNet/ZeroNet@454c0b2e7e (2026-09-02). Data as JSON: /api/errors/7b3011c5fe8307a9. Report an issue: GitHub.