Skip to content

In-app update: Update Now downloads, installs and restarts DraftCraft - #5

Merged
SkryxDev merged 1 commit into
mainfrom
in-app-update
Nov 8, 2026
Merged

SkryxDev merged 1 commit into
mainfrom
in-app-update

Conversation

@SkryxDev

@SkryxDev SkryxDev commented Nov 8, 2026

Copy link
Copy Markdown
Member

What it does

The update window gets Update Now: DraftCraft downloads the new release, checks it, puts it in place of the running copy and offers Restart Now / Later. No more downloading the DMG, zip or AppImage by hand for every update.

  • A progress bar ("Downloading: 34.0 of 74.0 MB"), with Cancel.
  • Restart Now quits through the normal close, so unsaved drawings are asked about first. Cancelling that prompt keeps the app open, and the new version starts next time.
  • Later: the new version is already installed and opens at the next start.
  • Download still opens the release page. It's the only button when this copy can't replace itself (a build from source, a folder this account can't write, Intel Macs, Linux ARM).
Installed as Downloads Put in place
macOS DraftCraft.app (bundle id dev.skryx.draftcraft) draftcraft-macos-arm64.dmg mounted read-only; its app must have our bundle id and the release's version; copied beside the old one with ditto, then swapped in by renaming
Windows folder with DraftCraft.exe draftcraft-windows-{x64,arm64}.zip unzipped beside it; each running file renamed to *.old (Windows allows that), the new one moved in
Linux AppImage ($APPIMAGE) draftcraft-linux-x86_64.AppImage renamed over the old one

At the next start, what the swap left behind (the old app, *.old files, the staging folder) is deleted.

Why not craft_update::self_update

craft-update has a self-updater, but on macOS it only recognises bundles whose id is ai.storyteller.<id>, and on Windows it refuses unsigned builds (ours aren't signed). So crates/ui-egui/src/self_update.rs does the swap itself and reuses craft-update for the rest: Http::download (resumable, SHA-256 checked, cancellable), parse_sha256sums / apply_sums, and download_url_under (only https://github.com/SkryxDev/DraftCraft/releases/download/…).

Safety

  • Only our repository's release downloads. Every file must match SHA256SUMS.txt. Downloads are capped at 600 MB.
  • The Windows zip: entries that would land outside the folder are refused, and the number of files, total size and folder depth are capped. Nothing is moved in unless DraftCraft.exe is in the zip.
  • macOS: if putting the new app in place fails, the old one is moved back.
  • No unwrap, expect or panics outside tests; every step returns an error, shown in the window together with the Download button.

Tried

  • On macOS, for real: a 2.0.2 build in a copy of DraftCraft.app, run with DRAFTCRAFT_PRETEND_VERSION=2.0.0. Update Now downloaded the live v2.0.1 DMG, checked and swapped it, and Restart Now opened DraftCraft 2.0.1, with a valid signature.
  • Windows and Linux: unit tests on temporary folders (replace and keep the old files aside, a hostile zip refused, AppImage replaced, cleanup at start). A real run is only possible once a release exists.
  • cargo xtask ci

Versions

  • Version 2.0.2. Merging doesn't release anything: the release is built by the v2.0.2 tag.
  • 2.0.0 and 2.0.1 don't have this yet: their users install 2.0.2 by hand once (their Download button opens the page), then every later update installs itself.
  • docs/releasing.md notes that the release file names, the zip's DraftCraft/ folder and SHA256SUMS.txt must stay as they are, or installed copies can no longer update themselves.

🤖 Generated with Claude Code

The update window gets Update Now beside Download: DraftCraft downloads the
new release, checks it against the release's SHA256SUMS.txt, puts it in place
of the running copy and offers Restart Now / Later. A progress bar shows the
download, Cancel stops it; Restart Now quits through the normal close, so
unsaved drawings are asked about first.

- crates/ui-egui/src/self_update.rs: how this copy was installed (macOS
  DraftCraft.app with bundle id dev.skryx.draftcraft, a Windows folder with
  DraftCraft.exe, a Linux AppImage), the release file it updates from, the
  download (craft_update::Http::download: resumable, SHA-256 checked, only
  SkryxDev/DraftCraft release downloads), the swap (macOS: the app copied out
  of the read-only mounted DMG, its bundle id and version checked, swapped in
  by renaming; Windows: unzipped beside it, running files renamed to *.old;
  Linux: renamed over the AppImage), the relaunch after the window closes and
  the cleanup of leftovers at the next start. Any other copy (a build from
  source, a folder this account can't write) keeps the release page.
- updates_ui.rs: Update Now, the progress, installed and failed windows; a
  cancelled unsaved-changes prompt cancels the relaunch.
- main.rs: leftovers cleaned at start, the relaunch after run_native returns.
- Italian and Chinese strings; docs/releasing.md says which release names
  installed copies depend on. Version 2.0.2.

craft_update::self_update isn't used: it only recognises ai.storyteller.*
bundles on macOS and refuses unsigned builds on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SkryxDev
SkryxDev merged commit d9834ef into main Nov 8, 2026
1 check passed
@SkryxDev
SkryxDev deleted the in-app-update branch November 8, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant