wip(0.S3): the packages migrated by ludic migrate state packages - every package test green
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1e8b5b0523
commit
07505e7ef2
294 changed files with 14996 additions and 14675 deletions
|
|
@ -1,87 +1,87 @@
|
|||
# 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() -> bool {
|
||||
if not update_installed() {
|
||||
update__err = UPDATE_ERR_NOT_INSTALLED
|
||||
export function update_start(base_st: mut BaseState, update_st: mut UpdateState) -> bool {
|
||||
if not update_installed(update_st) {
|
||||
update_st.update__err = UPDATE_ERR_NOT_INSTALLED
|
||||
return false
|
||||
}
|
||||
update__release()
|
||||
Fs.mkdir(update_packages())
|
||||
update__err = UPDATE_ERR_NONE
|
||||
update__h = UpdateNet.get(update__conf().feed + "/" + update__feed_file())
|
||||
if update__h < 0 {
|
||||
update__fail(UPDATE_ERR_UNREACHABLE)
|
||||
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(base_st, update_st, UPDATE_ERR_UNREACHABLE)
|
||||
return true
|
||||
}
|
||||
update__state = UPDATE_FEED
|
||||
update_st.update__state = UPDATE_FEED
|
||||
return true
|
||||
}
|
||||
|
||||
function update__release() -> void {
|
||||
if update__h >= 0 { UpdateNet.free(update__h) }
|
||||
update__h = -1
|
||||
if update__proc >= 0 { UpdateProc.free(update__proc) }
|
||||
update__proc = -1
|
||||
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(err: int) -> void {
|
||||
update__release()
|
||||
update__err = err
|
||||
update__state = UPDATE_FAILED
|
||||
update__fact(UPDATE_STOPPED)
|
||||
function update__fail(base_st: mut BaseState, update_st: mut UpdateState, err: int) -> void {
|
||||
update__release(update_st)
|
||||
update_st.update__err = err
|
||||
update_st.update__state = UPDATE_FAILED
|
||||
update__fact(base_st, 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(i: int) -> void {
|
||||
update__i = i
|
||||
let p = update__path(i)
|
||||
if Fs.exists(p) and Fs.size(p) == update__size[i] {
|
||||
update__check(i)
|
||||
function update__fetch(base_st: mut BaseState, 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(base_st, update_st, i)
|
||||
return
|
||||
}
|
||||
if Fs.exists(p) { Fs.remove(p) }
|
||||
update__h = UpdateNet.download(update__conf().feed + "/" + update__files[i], p)
|
||||
if update__h < 0 {
|
||||
update__fail(UPDATE_ERR_UNREACHABLE)
|
||||
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(base_st, update_st, UPDATE_ERR_UNREACHABLE)
|
||||
return
|
||||
}
|
||||
update__rate_t = -1
|
||||
update__state = UPDATE_FETCH
|
||||
update_st.update__rate_t = -1
|
||||
update_st.update__state = UPDATE_FETCH
|
||||
}
|
||||
|
||||
function update__hash_file() -> string {
|
||||
if len(update__conf().scratch) > 0 { return update__conf().scratch }
|
||||
function update__hash_file(update_st: mut 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(i: int) -> void {
|
||||
let out = update__hash_file()
|
||||
function update__check(base_st: mut BaseState, 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(i)) + ").Hash | Out-File -Encoding ascii -LiteralPath " + update__psq(out))
|
||||
update__proc = UpdateProc.spawn(update__powershell(), args)
|
||||
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(i) + "' | cut -d' ' -f1 > '" + out + "'")
|
||||
update__proc = UpdateProc.spawn("/bin/sh", args)
|
||||
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__proc < 0 {
|
||||
update__fail(UPDATE_ERR_CHECK)
|
||||
if update_st.update__proc < 0 {
|
||||
update__fail(base_st, update_st, UPDATE_ERR_CHECK)
|
||||
return
|
||||
}
|
||||
update__state = UPDATE_CHECK
|
||||
update__step_t0 = UpdateWorld.now_ms()
|
||||
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() -> string {
|
||||
let s = Fs.read_text(update__hash_file())
|
||||
function update__hash_read(update_st: mut 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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue