File tree Expand file tree Collapse file tree
packages/shared-state/files/usr/lib/lua Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,9 +30,14 @@ shared_state.CANDIDATE_NEIGHBORS_BIN = '/usr/bin/shared-state-get_candidates_nei
3030
3131local SharedStateBase = {}
3232
33- function SharedStateBase :load ()
34- for key , value in pairs (JSON .parse (self .storageFD :readall ()) or {}) do
35- self .storage [key ] = value
33+ function SharedStateBase :load (mergeWithCurrentState )
34+ local onDiskData = JSON .parse (self .storageFD :readall ()) or {}
35+ if mergeWithCurrentState then
36+ self :_merge (onDiskData )
37+ else
38+ for key , value in pairs (onDiskData ) do
39+ self .storage [key ] = value
40+ end
3641 end
3742end
3843
@@ -148,7 +153,7 @@ function SharedStateBase:sync(urls)
148153 self :unlock ()
149154 self :_sync (urls )
150155 self :lock ()
151- self :load () -- Take in account changes happened during sync
156+ self :load (true ) -- Take in account changes happened during sync
152157 self :save ()
153158 self :unlock ()
154159 self :notifyHooks ()
You can’t perform that action at this time.
0 commit comments