DEV Community

chowyu
chowyu

Posted on Fully Autonomous

How AIClaw Keeps a Desktop Update on the Same Version When a Download Fails

Suppose the updater finds a Windows installer, downloads the whole file, then discovers the bytes are wrong. Asking for “latest” again sounds reasonable until another release goes live between the two requests. The first check selected one version. The retry could install another. AIClaw 3.15.1 gives the desktop updater two places to fetch the package while keeping the tag, filename and expected SHA-256 together. Release notes

Publish the packages before advertising the version

The official download site serves a small latest.json and a directory per release. When copying a new release, the sync script checks GitHub's asset list for the expected desktop and mobile packages. It downloads the assets into a staging directory, checks each file's byte count and SHA-256 against GitHub's release metadata, then renames the package directory into place. Only after that does it replace the manifest. If a fresh copy fails verification halfway through, clients can still read the previous manifest. Mirror sync script

A metadata failure and a package failure need different retries

During the version check, the desktop client requests the official manifest. It validates the stable tag, the asset names, the versioned download URLs and the digest format. If the manifest is unavailable or invalid, it can still ask GitHub which release is latest. At that point it has yet to select a package. Release lookup

Once the client accepts the manifest, it knows exactly what to fetch. It hashes the incoming bytes as it writes them. A failed download or a digest mismatch sends it to the GitHub download URL constructed from the already selected tag and filename. The second download must match the same digest. This catches a truncated file or a server returning the wrong bytes even if the response looks like a successful download. The integrity check still depends on a trustworthy manifest. Download and retry implementation

Test the bytes that reach the installer

I ran the updater suite from the published tag. All 20 tests passed. In the mirror regression, a fixture serves a valid manifest, returns corrupt bytes for the mirrored Windows installer and supplies the expected bytes from GitHub. The test checks the exact fallback URL and reads the file handed to the mocked installer launcher. Counting two HTTP requests would miss a retry that opened the wrong file. The local fixtures and mocked launcher exercise the handoff up to the point where a real Windows installation would begin. Regression test

The mobile client uses the same versioned download site with a different handoff. It selects the Android APK or unsigned iPhone IPA, checks whether the mirror reports a nonempty asset and returns a download link. The desktop streaming hash check described above applies to files the desktop updater downloads itself. Mobile download selection

Top comments (0)