mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
hark-store: rebuild cache on inconsistency, instead of crashing
Addresses #4201, although the root cause of the cache inconsistency is still at large.
This commit is contained in:
parent
85435e9a81
commit
8fe8cfd29e
@ -338,6 +338,9 @@
|
|||||||
|= [read=? time=@da =index:store]
|
|= [read=? time=@da =index:store]
|
||||||
poke-core(+.state (^upd-cache read time index))
|
poke-core(+.state (^upd-cache read time index))
|
||||||
::
|
::
|
||||||
|
++ rebuild-cache
|
||||||
|
poke-core(+.state (inflate-cache -.state))
|
||||||
|
::
|
||||||
++ put-notifs
|
++ put-notifs
|
||||||
|= [time=@da =timebox:store]
|
|= [time=@da =timebox:store]
|
||||||
poke-core(notifications (put:orm notifications time timebox))
|
poke-core(notifications (put:orm notifications time timebox))
|
||||||
@ -380,17 +383,28 @@
|
|||||||
(~(put by archive-box) index notification(read %.y))
|
(~(put by archive-box) index notification(read %.y))
|
||||||
(give %archive time index)
|
(give %archive time index)
|
||||||
::
|
::
|
||||||
|
:: if we detect cache inconsistencies, wipe and rebuild
|
||||||
|
:: TODO: where are these coming from?
|
||||||
++ change-read-status
|
++ change-read-status
|
||||||
|= [time=@da =index:store read=?]
|
|= [time=@da =index:store read=?]
|
||||||
|
^+ poke-core
|
||||||
=. poke-core (upd-cache read time index)
|
=. poke-core (upd-cache read time index)
|
||||||
%_ poke-core
|
=/ t=(unit timebox:store)
|
||||||
notifications
|
(get:orm notifications time)
|
||||||
%^ jub-orm notifications time
|
?~ t poke-core
|
||||||
|= =timebox:store
|
=/ n=(unit notification:store)
|
||||||
%+ ~(jab by timebox) index
|
(~(get by u.t) index)
|
||||||
|= n=notification:store
|
?~ n poke-core
|
||||||
?>(!=(read read.n) n(read read))
|
=? poke-core
|
||||||
==
|
:: cache is inconsistent iff we didn't directly
|
||||||
|
:: call this through %read-note or %unread-note
|
||||||
|
&(=(read read.u.n) !?=(?(%read-note %unread-note) -.in))
|
||||||
|
rebuild-cache
|
||||||
|
=. u.t
|
||||||
|
(~(put by u.t) index u.n(read read))
|
||||||
|
=. notifications
|
||||||
|
(put:orm notifications time u.t)
|
||||||
|
poke-core
|
||||||
::
|
::
|
||||||
++ read-note
|
++ read-note
|
||||||
|= [time=@da =index:store]
|
|= [time=@da =index:store]
|
||||||
|
Loading…
Reference in New Issue
Block a user