49 lines
2.4 KiB
Text
49 lines
2.4 KiB
Text
# chain.ludic - the plan made: the files to fetch, in order, and the base the first delta patches
|
|
function update__plan_clear(update_st: mut UpdateState) -> void {
|
|
update_st.update__files = new []string
|
|
update_st.update__sha = new []string
|
|
update_st.update__size = new []int
|
|
update_st.update__delta = new []bool
|
|
update_st.update__ver = new []string
|
|
update_st.update__full = new []string
|
|
update_st.update__total_bytes = 0
|
|
update_st.update__done_bytes = 0
|
|
update_st.update__i = 0
|
|
}
|
|
|
|
# the plan from a parsed feed; false when there is nothing newer than this version
|
|
export function update_plan(update_st: mut UpdateState, feed: Val) -> bool {
|
|
update__plan_clear(update_st)
|
|
let as = update__assets(update_st, feed)
|
|
let n = update__newest_full(as)
|
|
if n < 0 or not update_newer(as[n].ver, update__conf(update_st).version) { return false }
|
|
let newest = as[n]
|
|
update_st.update__target = newest.ver
|
|
let base = update_packages(update_st) + update__sep() + update__full_name(update_st, as, update__conf(update_st).version)
|
|
let chain = update__chain(update_st, as, newest.ver)
|
|
var chain_bytes = 0
|
|
for i in 0 .. len(chain) { chain_bytes += chain[i].size }
|
|
let whole = len(chain) > 0 and len(chain) == update__fulls_after(update_st, as)
|
|
if Fs.exists(base) and whole and chain_bytes < newest.size {
|
|
for i in 0 .. len(chain) { update__plan_add(update_st, chain[i], update__full_name(update_st, as, chain[i].ver)) }
|
|
update_st.update__old = base
|
|
} else {
|
|
update__plan_add(update_st, newest, newest.file)
|
|
update_st.update__old = ""
|
|
}
|
|
return true
|
|
}
|
|
|
|
# the plan, for a panel or a test
|
|
export function update_package_count(update_st: UpdateState) -> int {
|
|
if update_st.update__files == null { return 0 }
|
|
return len(update_st.update__files)
|
|
}
|
|
|
|
export function update_plan_file(update_st: UpdateState, i: int) -> string { return update_st.update__files[i] }
|
|
export function update_plan_is_delta(update_st: UpdateState, i: int) -> bool { return update_st.update__delta[i] }
|
|
export function update_plan_version(update_st: UpdateState, i: int) -> string { return update_st.update__ver[i] }
|
|
export function update_target(update_st: UpdateState) -> string { return update_st.update__target }
|
|
export function update_total_bytes(update_st: UpdateState) -> int { return update_st.update__total_bytes }
|
|
|
|
function update__path(update_st: UpdateState, i: int) -> string { return update_packages(update_st) + update__sep() + update_st.update__files[i] }
|