Skip to content

Commit 1e50aa4

Browse files
committed
shared-state: fix sync not updating keys
1 parent b6ab59c commit 1e50aa4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/shared-state/files/usr/lib/lua/shared-state.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ shared_state.CANDIDATE_NEIGHBORS_BIN = '/usr/bin/shared-state-get_candidates_nei
3030

3131
local 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
3742
end
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()

0 commit comments

Comments
 (0)