Files
OrcaSlicer/docs/HLSD/updater.md
Lam Wei Lun e38aef0f33 Drop the Nightly update channel and serve the appcast from Cloudflare KV
The macOS update feed moves from GitHub Pages to the orcaslicer_updater
worker's Cloudflare KV, served at
https://check-version.orcaslicer.com/appcast.xml. publish_appcast.yml
uploads the generated feed to the KV namespace instead of pushing to
gh-pages, and version.inc advertises the new URL.

The Nightly channel is removed everywhere: UpdateChannel::Nightly and its
resolver branches, the Preferences option, the helper and GUI labels, the
skip_artifact setting, the nightly appcast CI job, and the docs. Only
Stable and Pre-Release remain; a -dev version counts as Pre-Release.
2026-12-04 20:10:13 +08:00

27 KiB

In-app updater — High Level Design

Why it exists

OrcaSlicer is installed by many routes: an NSIS installer, a portable zip, a DMG, an AppImage, Flatpak, the Microsoft Store, or a distribution package. Before this subsystem the application could only tell the user that a newer release existed and open a browser; what to download, and whether the application could replace itself, was left to them.

The updater answers three separate questions:

  • What is newer? Resolved from two inputs: the running build's identity and the channel the user picked.
  • What kind of install is this? A flavour derived from the filesystem, which decides whether an artifact can be downloaded or installed at all.
  • How does the swap happen? Either the application replaces itself with a small helper process, or it hands the user the right file and gets out of the way.

The work is split so that the first question is pure and testable, and the third is the only part that needs a platform-specific implementation.

Channels and identity

A channel says which releases may be offered:

Channel Release it resolves to Skip is keyed by
Stable the newest tag that is not a prerelease version
Pre-Release the newest tag of any kind, alpha, beta, rc or final version

update_channel_from_key() maps the stored string; anything unrecognised resolves to Stable, so a damaged configuration can only ever be more conservative.

The identity of a build is the digest of the artifact it came from, not its version string. The digest is recorded by the install itself and read on the next start.

A release is offered even when it has no digest or no asset for this platform: the caller then opens the Store, Flathub or the release page instead of installing. A release that cannot be installed is still news, and hiding it would leave the user on a stale build forever.

Switching channel offers that channel's current artifact even when it sorts lower, so a pre-release user who chooses Stable graduates to the final release. A build installed outside the application carries no channel, so the channel is read from its version instead: -dev, -rc, -beta and -alpha are pre-release, the rest stable, and an unparseable version counts as stable. That inferred channel may only switch to a candidate that does not sort lower, and a version that cannot be compared takes no switch at all: otherwise a hand-installed 2.6.0-rc1 would be offered an older stable on a switch, and a click would replace a newer build with an older one.

resolve_update() performs the whole decision and returns a candidate plus a reason string for the log. It is pure — no network, no wx, no globals — so every rule above is covered by tests/libslic3r/update_channel_tests.cpp without a fixture.

Install flavours

The flavour is decided once per run from filesystem and environment facts:

Flavour Recognised by Update path
windows_installer uninstall.exe beside the executable in-app
windows_portable neither that file nor a build tree direct download
macos_bundle running from .app/Contents/MacOS, writable volume Sparkle
linux_appimage $APPIMAGE and $APPDIR, executable under $APPDIR direct download
flatpak /.flatpak-info Flathub page
msix Windows package identity Microsoft Store
other distro package, source build, build tree, read-only bundle release page

in_app_install_supported() and is_download_only() name the two special cases, so the GUI decides a button label once and the helper is only ever started for a flavour that can use it. An executable inside a CMake build tree resolves to other on both Windows and macOS: a development build must never replace the tree it runs from.

macOS does not go through any of the resolving below. The bundle asks Sparkle, which reads its own feed; the channel only decides which feed it reads.

The flows

Every check resolves the same way. When something newer exists, the prefetch helper downloads it, verifies it, records a verified marker beside the artifact and exits. The application keeps running and shows a notification:

check → resolve_update → prefetch (download, verify, mark) → notification
                                                              ↓
                                                     user opens the dialog
                                                              ↓
                                    install helper (lock, verify, swap, record, relaunch)

Nothing installs without that click. There is no install at quit: quitting in any state leaves the verified artifact in the cache, and the next start notifies again.

update_action() owns the choice between doing nothing, prefetching and notifying, and takes readiness as an input on top of the skip and manual-check rules. It is pure, so the policy is tested rather than observed. Readiness is a filesystem fact: download_is_verified() requires the artifact at its expected size and a marker naming the candidate's digest, because the helper renames the file before verifying it.

The notification carries one action, which opens the same dialog as Help → Check for Updates: release notes, channel, "Install and restart", "Skip this Version", "Cancel". A manual check opens that dialog for any offer, verified or not: "Install and restart" starts the helper, which downloads what the cache does not hold yet. A manual check that finds nothing answers "This is the newest version." The automatic check never opens it. A reply that is not a release list at all is a failed check, not an empty one: the release on offer stays, and a manual check says it could not check rather than claiming the build is newest.

Neither the notification nor the candidate is persisted. The next check recomputes both from the release list and the cache, which is why an artifact that finished while the application was closed still produces a notification at the next start.

Skip this Version stops offering that build and deletes the cached artifact. The deletion takes the install lock and a per-download lock, because a prefetch helper started before a restart may still be writing the .part, or an install may be using it; when either lock is held, the deletion is deferred to the next skipped check.

In stealth mode the startup check does not run, because it starts a background download; the re-check after a channel change and Help → Check for Updates still run, and both answer with the dialog.

A failed download leaves a message in update_failed-<install>.txt, which the next start shows as a notification; the detailed trail is in updater.log. A failed install is visible in the helper window instead, because every install is started by the user.

The helper's window is the startup splash, in an ordinary frame so that the user can reach it from the taskbar. It draws in the theme the handoff names, because the application's own window is the one the user was using a moment before, and falls back to the system theme. Its Cancel button exists only while the download runs: before it the helper waits for the application to close, and an install already in flight cannot be undone.

What the two processes exchange

Everything travels through the OS cache directory, never the data directory: it holds a download the user can lose, and the data directory is small and synced. The application resolves the cache and puts its path in the handoff, because the helper's environment may resolve a different one. This is the Windows path; macOS hands the same three questions to Sparkle and keeps no state of its own.

Downloads are kept per install, under downloads/<install identity>/, keyed by the tree the application runs from; the extracted helper and the handoff that names the job are keyed the same way. Two installs share one cache, and each one downloads the artifact for its own platform and channel: a single directory would let one install consume a file the other had verified, run a helper the other extracted, or overwrite the job the other had handed to its helper. The pending-swap record and the installed record are keyed the same way, so one install cannot settle, overwrite or delete the record of another.

File Written by Read by Purpose
handoff-<install>-<job>.json app helper, once the job: asset, digest, size, install root, parent pid, lock path, theme. A prefetch and an install each get their own, so neither consumes the other's
installed-<install>.json helper app, next start what was installed, and the tree it belongs to
pending-<install>.json helper, before the swap app, next start the swap in flight; on macOS the tree moved aside, for rollback and cleanup
install.lock app, then helper both an OS file lock held for the life of the holder
download.lock the helper that downloads app, skip path held while a download writes; a skip or an install defers while it is held
<artifact>.verified prefetch helper, after verification app the digest the artifact verified for
update_failed-<install>.txt helper app, next start why a background download failed
downloads/<install>/, helper/<install>/, updater.log both both artifact, extracted helper, log

The digest of the build a .part belongs to is recorded beside it, so a resumed download can never be appended to a file for a different build. A .part that is already the size of the release is verified instead of fetched again, and a verified artifact is kept until it is installed rather than downloaded once per start. The artifact is reported ready only when a .verified marker beside it names the candidate's digest: the helper renames the file before verifying it, so the name and its size are not identity.

A download whose size or digest does not match the listing is dropped with its digest marker, so the next check fetches it again rather than trusting its size. A file that cannot be read is set aside instead: a read error says nothing about the bytes, so the check is repeated on the next start rather than the file being thrown away.

The lock is an OS-level lock on an open handle, not a pid file: the OS releases it when the holder dies, and a held lock cannot be read through another handle, so it carries no state. The file stays behind, empty, and the next holder locks it again: deleting it would let a waiter lock the unlinked handle while another process locks a new file under the same name. It prevents two installs, and the cleanup respects it. A second lock in the download directory is held by whichever helper downloads, so a skip's cleanup and an install that follows a click both wait or refuse rather than race it. The helper releases it once the new build is in place and recorded, before it starts it: the new build's own startup settles those records, and must not find the lock held.

Installing

Windows. The installer is packaging/windows/orca-slicer.nsi, built by makensis over a tree staged with cmake --install; it is not a CPack generator, because CPack's template forces administrator rights and Program Files. It has one scope, the one the CPack installer had: an all-users tree under %PROGRAMFILES64%\OrcaSlicer, an entry in HKLM's 32-bit view, which is where every installer so far has written it, and shortcuts in the all-users profile.

The entry stays in that view because the key is the product, not the tree: an upgrade from any earlier installer rewrites the same key instead of adding a second OrcaSlicer to the installed-apps list, and Windows reads both views alike. Before writing it, the installer deletes the entry wherever an earlier install left one: both views of HKLM, and the starting account's own hive under HKU, which is where a per-user build of an earlier revision wrote it. It deletes such a key only when it names the tree being installed, or when the tree it names no longer holds the executable. A key naming another live tree stays, because that install still runs and its entry is true.

A tree a record in the machine hive names is used when the installer is started without /D=, and a tree the caller marks with --tree-named — the marker the helper's install job passes — is used as given unless it disagrees with that record; either way the scope is the same. The marker exists because NSIS strips /D= from its own command line, so a tree named as the default and a double-click are indistinguishable once the parameters are parsed, and a copy that named its own tree must not be taken for one that named nothing. A named tree that disagrees with the record is refused rather than installed: the payload would replace the recorded tree and leave that install's record pointing at a different copy.

The installer is the only one that resolves the record; the helper decides elevation from writability alone and reads no record. The installer takes the 64-bit view first, then WOW6432Node, which is where the 32-bit installers write and where this one writes its own, and within a view InstallLocation, else the CPack-era Software\SoftFever\OrcaSlicer default value, else UninstallString. It expands a REG_EXPAND_SZ value and drops trailing separators before comparing, so one tree never reads as two strings.

Install and update both write a stage and swap it in, entirely inside the tree: a sibling <tree>.new would need create and delete rights on %PROGRAMFILES64%, which the user does not have. The new tree is written to <tree>\.stage, with a stage left behind by an earlier failed run removed first so it cannot merge with the payload.

The old uninstaller is not run. It removes the whole tree, including the stage. Every top-level child is renamed into <tree>\.old instead, then the staged children are moved up, orca-slicer.exe last so the tree never becomes runnable half-written, and .old is deleted. Because the tree directory itself is never deleted, its DACL, and the ACE above, survive every update.

A run that stops halfway leaves .stage and .old behind. Running the installer again clears both and finishes; the helper's retry does exactly that, so nothing new is recorded for it.

The installer reports five codes of its own. 1 is unused. 2 means nothing was written: the stage could not be written, a tree left by a crashed install could not be cleared, or the tree the caller named disagrees with the record. 3 means the tree changed and the new one could not be put in place. 4 means the installer handed the work to an elevated copy and exited, which the helper reports as an update in progress rather than as a failure. 5 means the swap completed and the previous tree could not be deleted, which the helper reports as a finished install: the new build is in place, so it records it and starts it, and the next update clears what was left behind.

Authorization. The installer never asks for a token it was not started with. .onInit re-launches itself through runas, forwarding /S and the /D= it was given, unless an HKLM record names this tree and this process can write to it. So a first install elevates whatever the folder's current permissions are, because writing the HKLM entry needs the token even where the tree itself is writable, and every later update runs unelevated.

That works because an elevated install grants the interactive user an inheritable ACE on the tree: modify, for the SID an unelevated process hands it rather than the one the elevated token carries, so an administrator elevating on someone's behalf does not grant it to themselves. The grant is applied only when elevated, and it survives every update because the swap never deletes the tree itself. A tree that predates the grant — a CPack-era install — elevates once for its first update and is quiet afterwards.

The grant goes through icacls.exe in System32, a Microsoft-signed program, called as icacls "$INSTDIR" /grant "*<SID>:(OI)(CI)M" after the stage is written and before the swap. The letters make the entry inheritable by everything the tree holds, which is what the rename-swap needs. icacls adds it to the directory's list and leaves the rest of the list alone, and it rewrites the entry that SID already has instead of adding a second, so a repeated run changes nothing.

The SID comes from the unelevated process, which is the one that runs as the user: the helper passes its own token's user SID as --grant-sid, and the installer passes what whoami reports when it re-launches itself. Nothing OrcaSlicer builds is executed under an administrator token, and that is the point of the indirection: the tree is writable by the user the grant is for, so a binary read from it between extraction and execution could be another one. A missing or malformed SID skips the grant with the same note a failed one prints; the install still goes in.

The helper decides nothing but writability: it starts the installer unelevated when the tree is writable and through runas otherwise. It verifies the downloaded artifact and holds it open through the install, and refuses while another process runs an image from the tree, for up to 30 seconds.

The helper reports a failure in its window, and records it for the next start only when it has no window. It adds that the previous version was removed only when the executable is no longer in the tree after the installer stopped, which with the stage and swap means the installer reached the point where the old children were moved aside and could not finish; every other failure leaves a version that still runs.

The Apps & features entry is written only by an elevated run, because HKLM needs the token. DisplayIcon, InstallLocation and UninstallString do not change between releases, so the only thing that lags is DisplayVersion, which shows the version last installed with a token.

Uninstalling. The uninstaller removes the machine record when it names the tree it sits in, and nothing when the tree is not recorded: a copied tree has no entry to remove. The Start-menu folder and the desktop shortcut are deleted from the all-users profile. The CPack-era value in Software\SoftFever\OrcaSlicer that names the tree is removed with it, in both registry views, and an install that replaces a tree removes the value naming that tree too. A leftover would let the next uninstall or the next double-click read a folder that no longer exists as a machine-wide record, and retarget to it. It removes a .stage and an .old left by a failed update as well, since those are this install's payload.

The uninstaller still needs a token for the HKLM entry and the all-users shortcuts, so un.onInit re-launches it through runas. That is also the one elevated path into a user-writable tree that the grant leaves open; see Limits.

macOS. Sparkle owns the update. MacUpdater.mm holds one SPUStandardUpdaterController, and the only thing OrcaSlicer decides is which channel it reads: one appcast for Stable and Pre-Release, where pre-release entries are tagged as a Sparkle channel. Sparkle reads the feed, verifies the archive's EdDSA signature and the new bundle's designated requirement against the one that is running, mounts the DMG, swaps the bundle, keeps its own rollback, and asks for an administrator's authorization only when the bundle or its parent is not writable — one prompt, never a permanent helper. It also draws the update window, keeps Skip, and schedules its own checks.

Nothing on macOS goes through the handoff, the cache, the locks, the records or the helper.

What OrcaSlicer still owes Sparkle is the appcast: it is generated in CI from the release's DMG, signed with the EdDSA key, and uploaded to the updater worker's Cloudflare KV (APPCAST_KV), which serves it at https://check-version.orcaslicer.com/appcast.xml. A release that skipped that step ships a build that never sees an update, which is the one failure mode this design adds and the one the publish workflow must not miss.

Trust

Four checks stand between a downloaded file and the install on Windows, and none of them depends on the user reading a dialog:

  1. Origin. Only https://github.com/OrcaSlicer/OrcaSlicer/releases/download/ URLs are fetched, and only in the exact form <tag>/<asset name> — no .., no query, no other segment. The downloader keeps curl from normalising the path and accepts redirects only to https.
  2. Digest. The artifact's sha256 from the release listing is checked against the downloaded bytes. This proves the transfer, not the listing. A body larger than the size the listing announces is dropped as it arrives, so it cannot fill the disk before that check runs.
  3. Signature. The installer must verify with Authenticode.
  4. Publisher. The signer must be ours: the Authenticode signer's display name. The value is compiled in from the CI signing material, so the check names the certificate that actually signs the release. An empty value disables it with a warning, which is what a local or unsigned PR build wants and what a release build must not have.

Checks 3 and 4 together are what let a single click install the file without the user judging what it is.

macOS gets the same properties from Sparkle, by a different mechanism: the feed entry's EdDSA signature is checked against the key compiled into the bundle, and the downloaded bundle must satisfy the running bundle's designated requirement, which names the same Team ID. The archive is not hashed again; the signature covers it.

A release build carries the pin of its platform and cannot be configured without it: ORCA_RELEASE_BUILD=ON makes the configure fail when Windows has no publisher, macOS has no Sparkle public key, or either has no build timestamp to identify the build by, and every release build sets it. Each pin is read from the environment, which overrides the cached value whenever it is set — including set empty, which clears it — so a tree reconfigured after a publisher, key or timestamp was rotated or cleared cannot keep the old one. A developer tree that sets none of them keeps whatever its cache holds, which is what makes a local rebuild cheap.

Limits

  • Windows portable and AppImage builds download through the browser, so the digest is not checked for them; they also cannot replace themselves.
  • Known and accepted: the Windows tree is writable by the user it was installed for, which is what makes an update promptless. Anything running as that user can replace the binaries and the DLLs beside them. An update never runs anything from the tree as administrator, but Windows still uninstalls from there: Apps & features, winget and SCCM run uninstall.exe, which elevates itself and then loads the DLLs in that folder. So an administrator who uninstalls this copy, or a managed uninstall that runs as SYSTEM, executes files the installing user could have replaced. A maintenance service is the way out, by keeping the payload out of the tree; until one exists this is the price of an update that asks nothing.
  • The grant is for the installing user. A second account on the same machine can run the application but not update it, and its update prompts.
  • The ACE is applied through a junction or a substituted drive when $INSTDIR is one, because icacls follows the link.
  • DisplayVersion in Apps & features lags: only an elevated run writes HKLM.
  • On macOS the update is whatever Sparkle does; a release that fails to regenerate the appcast is a release nobody is offered.
  • The macOS floor is the deployment target the build was configured with, not a number in this file: the bundle's LSMinimumSystemVersion follows CMAKE_OSX_DEPLOYMENT_TARGET, and CI builds with 10.15. Sparkle is pinned to 2.9.6 for that reason alone — 2.10 raised the framework's own floor to macOS 12.0, and a framework dyld refuses to load raises the application's floor with it. Configure reads the framework's floor and fails when the deployment target is below it, so a Sparkle bump cannot silently drop macOS versions.
  • Sparkle cannot downgrade, so a Pre-Release user who switches to Stable stays on the pre-release until a newer stable ships.
  • A build that starts and then crashes is not rolled back on Windows: .old is gone and the previous build with it. Sparkle keeps its own rollback on macOS.
  • The Windows check for another running instance cannot see processes it has no permission to open.
  • Nothing installs while the application closes on Windows. Every update ends in a restart the user started. On macOS Sparkle schedules its own checks and installs in its own window.
  • A launch without a network cannot install a cached artifact: the asset URL and digest arrive with the check.
  • Skip deletes the cached artifact only when no helper holds the install or download lock, so a skipped build's file can survive one more check.

Where the code lives

Concern Files
channel, candidate, policy src/libslic3r/UpdateChannel.{hpp,cpp}
cache, records, lock, download preparation, URL allowlist src/libslic3r/UpdateHandoff.{hpp,cpp}
flavour detection, handoff, launching the helper src/slic3r/GUI/GUI_Utils.cpp, GUI_App.cpp
helper window, modes, verification src/slic3r/UpdateHelper/
the Windows elevation decision src/slic3r/UpdateHelper/InstallDecision.hpp
macOS updater src/slic3r/GUI/MacUpdater.{hpp,mm}
Windows installer packaging/windows/orca-slicer.nsi
macOS appcast scripts/sparkle_appcast.sh, .github/workflows/publish_release.yml

What CI checks

Three checks run on the artifacts themselves, because the parts that install cannot be unit-tested without the release credentials:

  • scripts/check_macos_bundle.sh reads the built bundle's plist in the macOS build job: CFBundleVersion is the build timestamp's digits, SUFeedURL is the one version.inc names, the schedule keys are the ones the design sets, LSMinimumSystemVersion is the deployment target the build was configured with, and a release build carries SUPublicEDKey. A wrong value there is an update path nobody notices until a user does.
  • scripts/smoke_windows_installer.ps1 installs the built installer silently on the Windows job, asserts one Apps & features entry in the 32-bit view with the right InstallLocation, then uninstalls it and asserts nothing is left. An entry added in the wrong registry view shows up as a second OrcaSlicer in the installed-apps list, and nothing else on that machine would say so.
  • tests/appcast/ runs scripts/sparkle_appcast.sh over throwaway images with a throwaway signing key and reads the feed back: one item per image, the enclosure URL, sparkle:version, the prerelease channel tag, and a refusal when an image carries no feed keys.

What none of them covers is the install itself: Sparkle's verification and bundle swap, and Authenticode on Windows, need the release certificate and the appcast key on a job that a pull request can change.