Commit Graph
6 Commits
Author SHA1 Message Date
Lam Wei Lun 397a8d9b1a Fix updater review blockers: URL allowlist, install lock, nightly identity
is_release_download_url was a prefix test, so a URL with ../ segments
passed it and curl collapsed them into another repository's path. It now
takes the asset name and accepts only <prefix><tag>/<asset_name> made of
plain characters, and the downloader sets CURLOPT_PATH_AS_IS.

The install lock took over a stale pid file with a read, a remove and a
create, so two takers could both win, and the file existed empty before
the pid was written. It now holds flock/LockFileEx on an open handle for
the life of the process; the OS drops it when the holder exits.

On Windows the helper waited only for the parent process. A second
OrcaSlicer running from the install folder kept files locked, and the
silent NSIS installer uninstalled first and then failed. The helper now
waits up to 30 s for such processes and refuses before anything changes.

A nightly installed by hand has no recorded digest and was compared with
the release's updated_at, which follows the last asset upload, so it was
offered itself on every check. The release now has to be more than six
hours newer than the build.

The update dialog was destroyed twice when the updater failed to start:
it lived on the stack while the main frame, its parent, was deleted.
It is now scoped before the install starts.

The install record names the install it belongs to, and only that copy
consumes it. It is read first and deleted after the install lock is
taken, so a held lock no longer leaves the download in the cache.

On macOS a user who cannot write the target's parent folder had no way
to stage the new bundle. It is staged in the cache and copied in by the
single administrator step.
2026-11-12 18:17:54 +08:00
Lam Wei Lun 033bdab681 Convert paths as UTF-8 in the non-ASCII handoff test
On Windows Boost.Filesystem reads a narrow path as the ANSI code page
unless nowide_filesystem() has run, while the handoff write goes through
nowide. The test created the cache directory under one name and wrote
into another. Do what the app does at startup.
2026-11-12 14:23:38 +08:00
Lam Wei Lun 4d794edc0b Fix the updater review findings: helper startup, Windows apply, recovery
The helper exited before reading its handoff because wx's command-line
parser rejected --handoff. Windows portable updates failed on tar.exe
lookup, a working directory inside the install, and the nightly zip's
top-level folder. The AppImage helper now ships with its own libraries.

- Restrict downloads to https GitHub release URLs, verify TLS on the
  version check, set CA certificates and FAILONERROR in the downloader.
- Rename the verified download to its asset name, hold it open on
  Windows, and relaunch the app when an update fails before the swap.
- Use nowide paths in the helper for non-ASCII Windows user names.
- Roll back by renaming the new tree aside; stage Linux copies beside
  the target; drop the predictable macOS marker file.
- Require $APPDIR for AppImage detection; reject read-only macOS volumes.
- Check for updates once after Preferences closes, and drop stale results.
- Offer releases without a matching asset, key Nightly skips by version,
  and let Pre-Release offer a newer final release.
- Find pending.json from a .backup copy and keep the backup unless the
  new build is running from the target.
- Move the build timestamp into its own generated header so it no
  longer invalidates ccache on every CI run.
2026-11-12 12:31:44 +08:00
Lam Wei Lun 5503be1117 Fix the updater build on macOS and Windows, and its download-directory test
posix_spawn takes environ from unistd.h on Linux, but Apple platforms keep
it behind _NSGetEnviron() from crt_externs.h, so the macOS build did not
compile.

libcurl's peer.c calls if_nametoindex, which lives in iphlpapi; the helper
is the only target that links libcurl without that library, so it failed
to link on Windows.

The test for dropping another build's partial download asserted the
digest marker was gone, but prepare_download_dir rewrites the marker for
the new build before it downloads, as the next test in the file requires.
Assert the marker now names the new build.
2026-11-12 01:08:36 +08:00
Lam Wei Lun 857a42c2d5 Add the includes clang-tidy's include check asks for
Every file the updater touches now names the headers for the symbols it
uses, instead of relying on a transitive include.
2026-11-11 17:20:22 +08:00
Lam Wei Lun e87a9833f2 Keep the updater cache in the OS cache and clean up after an install
The updater wrote everything it needed under the data directory: the
cache, its records, the downloaded artifact and the extracted helper.
Move the whole root to the OS cache directory, and give a portable
Windows install a suffixed folder there instead of %TEMP%, so a temp
sweep cannot strand a partial download.

Now that a finished install leaves nothing to resume, the next start
deletes the download and each helper run starts a fresh log, so neither
grows by one copy per update.

A partial download is resumed only for the build it was started for: the
digest is recorded beside it, and a .part already as large as the
release is verified again instead of being fetched a second time.

The download preparation lives in libslic3r so it can be tested, with
cases for a matching build, another build, a missing record, an
oversized file, a complete file and a sibling artifact.
2026-11-11 17:19:09 +08:00