From 4551c74e3a210b2db10f42c83359aec083ef5969 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 27 Mar 2020 12:38:08 +0100 Subject: [PATCH] group-hook: on %path group-update, don't %unbundle Instead, %bundle and %add if we don't have the group locally yet, or %add and %remove whatever the difference is between the local group and the group as specified in the %path update. --- pkg/arvo/app/group-hook.hoon | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/app/group-hook.hoon b/pkg/arvo/app/group-hook.hoon index b41a51ab4..5a2034015 100644 --- a/pkg/arvo/app/group-hook.hoon +++ b/pkg/arvo/app/group-hook.hoon @@ -191,10 +191,23 @@ =/ ship (~(get by synced.state) pax.diff) ?~ ship ~ ?. =(src.bol u.ship) ~ - :~ (group-poke pax.diff [%unbundle pax.diff]) - (group-poke pax.diff [%bundle pax.diff]) - (group-poke pax.diff [%add members.diff pax.diff]) - == + =/ have-group=(unit group) + (group-scry pax.diff) + ?~ have-group + :: if we don't have the group yet, create it + :: + :~ (group-poke pax.diff [%bundle pax.diff]) + (group-poke pax.diff [%add members.diff pax.diff]) + == + :: if we already have the group, calculate and apply the diff + :: + =/ added=group (~(dif in members.diff) u.have-group) + =/ removed=group (~(dif in u.have-group) members.diff) + %+ weld + ?~ added ~ + [(group-poke pax.diff [%add added pax.diff])]~ + ?~ removed ~ + [(group-poke pax.diff [%remove removed pax.diff])]~ :: %add :_ state