Repository navigation
Commit fffea30
authored
feat: apply a binary delta from the running version when the server offers one (#328)
Stacked on #327 (base branch `stream-and-resume-downloads`); the diff
here is only the delta work.
An update may now carry `delta`: a
[Sparkle](https://sparkle-project.org) BinaryDelta patch (format 3 or 4)
from one earlier `CFBundleVersion` to this release, with its URL, size
and SHA-256:
```json
"delta": { "from_version": "412", "url": "https://…/412-to-413.delta", "sha256": "…", "size": 7340032 }
```
When `from_version` is the running application's, Squirrel downloads the
patch instead of the ZIP (same streaming, resumable `SQRLDownloader`),
checks size and digest before opening it, applies it to a copy of the
running bundle inside the update directory, and sends the result through
the existing code signing and `ElectronSquirrelPreventDowngrades`
checks. If the delta is for another version, or downloading, verifying,
applying or checking it fails in any way, the full ZIP is downloaded in
the same check, so offering a delta can never cost an update. All four
keys are required; ShipIt and installation are untouched.
The apply side is Sparkle's own, vendored unmodified under
`Vendor/SparkleDelta` (MIT; format 3/4 reader and applier plus
`bspatch`, ~2.9k lines, pinned to sparkle-project/Sparkle@cfa1190) with
a small force-included config header standing in for Sparkle's xcconfig
defines; the legacy XAR formats and the create side are left out, so
patches are made with Sparkle's `BinaryDelta create old.app new.app
out.delta` from the exact signed bundles that shipped. That keeps one
implementation of the format rather than a Squirrel-flavoured second
one. `objc_direct` is turned off for the vendored classes so the tests
can link Sparkle's generator against them.
Sizing, for a sense of why: between two consecutive releases of a large
Electron app (~230 MB zipped per arch, same Electron version) the
format-4 LZMA delta is 9.5 MB, applies in a few seconds, and the result
is byte-identical to the shipped bundle and passes `codesign --verify
--deep --strict` and Gatekeeper.
Tests: `SQRLUpdaterSpec` builds real patches between the two
TestApplication fixtures with Sparkle's generator (vendored into the
test target only) and drives the out-of-process install twice, once from
the delta alone (ZIP never requested) and once with a corrupted delta
that must fall back to the ZIP, asserting on the fixture server's
request log which files were fetched; `SQRLUpdateSpec` covers parsing
and rejects a delta missing any key. 97 tests pass on macOS 26.5 / Xcode
26.5. README documents the key in both feed formats1 parent 61438d0 commit fffea30
16 files changed
Lines changed: 782 additions & 42 deletions
File tree
- .github/workflows
- Carthage/Checkouts
- Squirrel.xcodeproj
- SquirrelTests
- Squirrel
- SparkleDelta
- TestApplication
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
164 | 171 | | |
165 | 172 | | |
166 | 173 | | |
167 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
168 | 181 | | |
169 | 182 | | |
170 | 183 | | |
| |||
197 | 210 | | |
198 | 211 | | |
199 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
200 | 238 | | |
201 | 239 | | |
202 | 240 | | |
| |||
253 | 291 | | |
254 | 292 | | |
255 | 293 | | |
| 294 | + | |
256 | 295 | | |
257 | 296 | | |
258 | 297 | | |
| |||
0 commit comments