Skip to content

Download to a partial filename and rename on checksum success #207

@yashi

Description

@yashi

Currently download_thread() (via get_binary()) writes the artifact directly to bundle_download_location using g_fopen(file, "wb+") or "ab+" for resume. This makes it hard to reliably detect "download completed and verified" from outside the process.

In my case, I want to trigger an action after the updater has downloaded a bundle. There is no dedicated download-complete hook, so I tried using systemd.path. But because the final filename exists while the download is still in progress (and can be resumed later), and because checksum verification may fail after the download finishes, systemd.path cannot reliably tell when the file is actually ready.

Proposal

Add support for downloading to an in-progress filename (for example ${bundle_download_location}.part) and only renaming it to
${bundle_download_location} after the checksum has been verified successfully.

Suggested behavior

  1. Download and resume use the partial file path (stat and append the .part file).
  2. Compute checksum from the partial file.
  3. If checksum OK, rename .part to the final path (atomic rename on the same filesystem).
  4. If checksum fails, either keep the .part file for debugging, or delete it, but do not rename.

This would allow external watchers to safely use systemd.path on the final filename, because the final filename would only appear once the bundle is complete and verified.

References

We are happy to implement this feature if the overall design is OK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions