- the call graph is by name, and a local or a parameter named as a function (a float bd, part, bx) linked to that function: a name the function binds itself is never an edge now. - drain_actions, generated, calls every reducer; a reducer is reached from its action's dispatch, so the drain's calls are not edges. - a fresh value flowing into a local that also holds kept memory is still the frame's (storing it anywhere kept would have made it ESC): HEAP now keeps only a push's growth off the arena. - the arena starts at its first use rather than at the first frame mark, so boot's temporaries are scratch too - dead once the Start handlers return - and a scratch site is never a birth. Plus ludic.hints' rail and three of ludic.update's one-off lines declared. The arena goldens pass poisoned. Maroon Lake (d79d189f): 39/11/66 -> 30/9/0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.5 KiB
Text
93 lines
3.5 KiB
Text
# steps.ludic - each step started: the feed asked, a package streamed into the packages folder, its
|
|
# SHA-256 by a child (Get-FileHash, shasum) so the frame keeps drawing, a patch, the apply
|
|
# the Update button: false (and nothing started) when Velopack did not install this copy
|
|
export function update_start(update_st: mut UpdateState) -> bool {
|
|
if not update_installed(update_st) {
|
|
update_st.update__err = UPDATE_ERR_NOT_INSTALLED
|
|
return false
|
|
}
|
|
update__release(update_st)
|
|
Fs.mkdir(update_packages(update_st))
|
|
update_st.update__err = UPDATE_ERR_NONE
|
|
update_st.update__h = UpdateNet.get(update__conf(update_st).feed + "/" + update__feed_file())
|
|
if update_st.update__h < 0 {
|
|
update__fail(update_st, UPDATE_ERR_UNREACHABLE)
|
|
return true
|
|
}
|
|
update_st.update__state = UPDATE_FEED
|
|
return true
|
|
}
|
|
|
|
function update__release(update_st: mut UpdateState) -> void {
|
|
if update_st.update__h >= 0 { UpdateNet.free(update_st.update__h) }
|
|
update_st.update__h = -1
|
|
if update_st.update__proc >= 0 { UpdateProc.free(update_st.update__proc) }
|
|
update_st.update__proc = -1
|
|
}
|
|
|
|
function update__fail(update_st: mut UpdateState, err: int) -> void {
|
|
update__release(update_st)
|
|
update_st.update__err = err
|
|
update_st.update__state = UPDATE_FAILED
|
|
update__fact(update_st, UPDATE_STOPPED)
|
|
}
|
|
|
|
# fetch file i, unless a copy of the right size is there already - then straight to its check
|
|
function update__fetch(update_st: mut UpdateState, i: int) -> void {
|
|
update_st.update__i = i
|
|
let p = update__path(update_st, i)
|
|
if Fs.exists(p) and Fs.size(p) == update_st.update__size[i] {
|
|
update__check(update_st, i)
|
|
return
|
|
}
|
|
if Fs.exists(p) { Fs.remove(p) }
|
|
update_st.update__h = UpdateNet.download(update__conf(update_st).feed + "/" + update_st.update__files[i], p)
|
|
if update_st.update__h < 0 {
|
|
update__fail(update_st, UPDATE_ERR_UNREACHABLE)
|
|
return
|
|
}
|
|
update_st.update__rate_t = -1
|
|
update_st.update__state = UPDATE_FETCH
|
|
}
|
|
|
|
@alloc_ok("once per package downloaded and checked")
|
|
function update__hash_file(update_st: UpdateState) -> string {
|
|
if len(update__conf(update_st).scratch) > 0 { return update__conf(update_st).scratch }
|
|
return Os.temp_dir() + "/ludic-update-hash.txt"
|
|
}
|
|
|
|
# no cmd.exe: it parses its own command line and would not survive Process.spawn's quoting
|
|
function update__check(update_st: mut UpdateState, i: int) -> void {
|
|
let out = update__hash_file(update_st)
|
|
if Fs.exists(out) { Fs.remove(out) }
|
|
let args = new []string
|
|
if UpdateWorld.platform() == "windows" {
|
|
push(args, "-NoProfile")
|
|
push(args, "-NonInteractive")
|
|
push(args, "-Command")
|
|
push(args, "(Get-FileHash -Algorithm SHA256 -LiteralPath " + update__psq(update__path(update_st, i)) + ").Hash | Out-File -Encoding ascii -LiteralPath " + update__psq(out))
|
|
update_st.update__proc = UpdateProc.spawn(update__powershell(), args)
|
|
} else {
|
|
push(args, "-c")
|
|
push(args, "shasum -a 256 '" + update__path(update_st, i) + "' | cut -d' ' -f1 > '" + out + "'")
|
|
update_st.update__proc = UpdateProc.spawn("/bin/sh", args)
|
|
}
|
|
if update_st.update__proc < 0 {
|
|
update__fail(update_st, UPDATE_ERR_CHECK)
|
|
return
|
|
}
|
|
update_st.update__state = UPDATE_CHECK
|
|
update_st.update__step_t0 = UpdateWorld.now_ms()
|
|
}
|
|
|
|
# the hash the child wrote: the first line with anything on it
|
|
function update__hash_read(update_st: UpdateState) -> string {
|
|
let s = Fs.read_text(update__hash_file(update_st))
|
|
if s == null { return "" }
|
|
let lines = Text.split(s, "\n")
|
|
for i in 0 .. len(lines) {
|
|
let t = Text.trim(lines[i])
|
|
if len(t) > 0 { return Text.upper(t) }
|
|
}
|
|
return ""
|
|
}
|