Skip to content

Commit

Permalink
channels: don't crash during "double join"
Browse files Browse the repository at this point in the history
Previously, if we tried to join a channel we already had state for, we
would crash.

Here, we do a check on our subs, reestablish them if needed, but
otherwise no-op. This lets us import channel state from backups without
it interfering with subsequent group rejoins. It also speeds up the
rejoins: we simply start fetching updates again from where we the
imported state left off.
  • Loading branch information
Fang- committed Aug 8, 2024
1 parent 6f7b378 commit faeb812
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion desk/app/channels.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@
:: we only restore miscellanea. groups' import should prompt us to
:: re-join channels, we won't bother pre-loading their content for now.
::
=. v-channels (~(uni by v-channels:bak) v-channels)
=. voc (~(uni by voc:bak) voc)
=. hidden-posts (~(uni in hidden-posts:bak) hidden-posts)
cor
Expand Down Expand Up @@ -890,8 +891,13 @@
++ ca-join
|= [n=nest:c group=flag:g]
=. nest n
?< (~(has by v-channels) nest)
?> |(=(p.group src.bowl) from-self)
?: (~(has by v-channels) nest)
:: we should already be in, but make sure our subscriptions still exist
:: just in case
::
=. channel (~(got by v-channels) nest)
(ca-safe-sub |)
=. channel *v-channel:c
=. group.perm.perm.channel group
=. last-read.remark.channel now.bowl
Expand Down

0 comments on commit faeb812

Please sign in to comment.