metadata: handle OTA correctly

This commit is contained in:
Liam Fitzgerald 2020-07-23 15:02:54 +10:00
parent a696cf38f2
commit 0eb3b2e77f
2 changed files with 54 additions and 8 deletions

View File

@ -10,14 +10,19 @@
+$ card card:agent:gall
+$ versioned-state
$% state-zero
state-one
==
::
+$ state-zero
$: %0
synced=(map group-path ship)
==
+$ state-one
$: %1
synced=(map group-path ship)
==
--
=| state-zero
=| state-one
=* state -
%- agent:dbug
%+ verb |
@ -32,7 +37,17 @@
[[%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~ this]
::
++ on-save !>(state)
++ on-load |=(=vase `this(state !<(state-zero vase)))
++ on-load
|= =vase
=/ old
!<(versioned-state vase)
?: ?=(%1 -.old)
`this(state old)
:: groups OTA did not migrate metadata syncs
:: we clear our syncs, and wait for metadata-store
:: to poke us with the syncs
`this
::
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-arvo on-arvo:def

View File

@ -21,8 +21,8 @@
:: /app-name/%app-name associations for app
:: /group/%group-path associations for group
::
/- *metadata-store
/+ *metadata-json, default-agent, verb, dbug
/- *metadata-store, *metadata-hook
/+ *metadata-json, default-agent, verb, dbug, resource
|%
+$ card card:agent:gall
::
@ -44,13 +44,19 @@
state-base
==
::
+$ state-two
$: %2
state-base
==
::
+$ versioned-state
$% state-zero
state-one
state-two
==
--
::
=| state-one
=| state-two
=* state -
%+ verb |
%- agent:dbug
@ -69,9 +75,26 @@
^- (quip card _this)
=/ old
!<(versioned-state vase)
?: ?=(%1 -.old)
`this(state old)
=| cards=(list card)
|-
|^
?: ?=(%2 -.old)
[cards this(state old)]
?: ?=(%1 -.old)
%_ $
old [%2 +.old]
::
cards
%+ turn
~(tap in ~(key by group-indices.old))
|= =group-path
^- card
=/ rid=resource
(de-path:resource group-path)
?: =(our.bowl entity.rid)
(poke-md-hook %add-owned group-path)
(poke-md-hook %add-synced entity.rid group-path)
==
=/ new-state=state-one
%* . *state-one
associations (migrate-associations associations.old)
@ -79,7 +102,15 @@
app-indices (migrate-app-indices app-indices.old)
resource-indices (migrate-resource-indices resource-indices.old)
==
`this(state new-state)
$(old new-state)
::
++ poke-md-hook
|= act=metadata-hook-action
^- card
=/ =cage
:_ !>(act)
%metadata-hook-action
[%pass / %agent [our.bowl %metadata-hook] %poke cage]
::
++ new-group-path
|= =group-path