From b41aaf8f10b1aac6f591b7860eaa2c783f218f35 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 21 Sep 2021 18:19:38 +0200 Subject: [PATCH] docket: stop eating fresh globs and their hashes When we uploaded a glob we hosted, we'd write a new docket to clay, triggering a %commit. The handling of this would: - fail to update the docket in state, - and discard our new glob, because the docket had changed. Here we properly update the docket mirror in state, and make sure to keep the glob around if its hash lines up. --- pkg/garden/app/docket.hoon | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/pkg/garden/app/docket.hoon b/pkg/garden/app/docket.hoon index 4eb3ec523..fde02bcc6 100644 --- a/pkg/garden/app/docket.hoon +++ b/pkg/garden/app/docket.hoon @@ -196,25 +196,37 @@ %commit =* cha ~(. ch desk.diff) ?. docket-exists:cha `state - =/ =docket docket:cha + :: always update the docket in state to match clay's + :: + =/ =docket docket:cha + =/ pre=(unit charge) (~(get by charges) desk.diff) + =. charges (new-docket:cha docket) :: if the new chad is a site, we're instantly done :: ?: ?=(%site -.href.docket) :- ~[add-fact:cha] - state(charges (~(put by charges) desk.diff [docket [%site ~]])) - :: if the glob is unchanged, keep it + =. charges (new-chad:cha %site ~) + state :: - =/ pre=(unit href) - ?~ cho=(~(get by charges) desk.diff) ~ - `href.docket.u.cho - ?: =(pre `href.docket) + =. by-base (~(put by by-base) base.href.docket desk.diff) + :: if the glob specification is unchanged, keep it + :: + ?: &(?=(^ pre) =(href.docket.u.pre `href.docket)) + [~[add-fact:cha] state] + :: if the glob spec changed, but we already host it, keep it + :: (this is the "just locally uploaded" case) + :: + ?: ?& ?=(^ pre) + ?=(%glob -.chad.u.pre) + :: + .= [%ames our.bowl (sham glob.chad.u.pre)] + glob-location.href.docket + == [~[add-fact:cha] state] :: if the glob changed, forget the old and fetch the new :: - =. charges (~(put by charges) desk.diff [docket %install ~]) - =. by-base (~(put by by-base) base.href.docket desk.diff) - :_ state - [add-fact:cha fetch-glob:cha] + =. charges (new-chad:cha %install ~) + [[add-fact:cha fetch-glob:cha] state] :: %suspend ?. (~(has by charges) desk.diff) `state @@ -488,7 +500,6 @@ :: ?. ours ~ ^- (list card) - ::TODO for some reason this doesn't give us a %commit fact? =- [%pass /write/[desk] %arvo %c %info -]~ %+ foal:space:userlib /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/desk/docket @@ -589,6 +600,7 @@ (poke-our:(pass %install) %hood kiln-install+!>([desk ship remote])) ++ uninstall (poke-our:(pass %uninstall) %hood kiln-uninstall+!>(desk)) + ++ new-docket |=(d=^docket (~(jab by charges) desk |=(charge +<(docket d)))) ++ new-chad |=(c=chad (~(jab by charges) desk |=(charge +<(chad c)))) ++ fetch-glob ^- (list card)