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
- Download and resume use the partial file path (stat and append the
.part file).
- Compute checksum from the partial file.
- If checksum OK, rename
.part to the final path (atomic rename on the same filesystem).
- 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.
Currently
download_thread()(viaget_binary()) writes the artifact directly tobundle_download_locationusingg_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.pathcannot 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
.partfile)..partto the final path (atomic rename on the same filesystem)..partfile for debugging, or delete it, but do not rename.This would allow external watchers to safely use
systemd.pathon the final filename, because the final filename would only appear once the bundle is complete and verified.References
https://www.freedesktop.org/software/systemd/man/systemd.path.html
https://pubs.opengroup.org/onlinepubs/000095399/functions/rename.html
https://man7.org/linux/man-pages/man2/rename.2.html
g_rename():https://docs.gtk.org
We are happy to implement this feature if the overall design is OK.