Software /
code /
prosody
Comparison
plugins/mod_storage_memory.lua @ 9534:b301f7edf346
mod_storage_memory: Fix overwriting old keys
Test fixed is: spec/core_storagemanager_spec.lua:309: Expected objects to be equal.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 21 Oct 2018 18:00:46 +0200 |
parent | 9533:00a8e627854e |
child | 9535:c1befd1c886d |
comparison
equal
deleted
inserted
replaced
9533:00a8e627854e | 9534:b301f7edf346 |
---|---|
51 local a = self.store[username or NULL]; | 51 local a = self.store[username or NULL]; |
52 if not a then | 52 if not a then |
53 a = {}; | 53 a = {}; |
54 self.store[username or NULL] = a; | 54 self.store[username or NULL] = a; |
55 end | 55 end |
56 local i = #a+1; | |
57 local v = { key = key, when = when, with = with, value = value }; | 56 local v = { key = key, when = when, with = with, value = value }; |
58 if not key then | 57 if not key then |
59 key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; | 58 key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; |
60 v.key = key; | 59 v.key = key; |
61 end | 60 end |
62 if a[key] then | 61 if a[key] then |
63 table.remove(a, a[key]); | 62 table.remove(a, a[key]); |
64 end | 63 end |
64 local i = #a+1; | |
65 a[i] = v; | 65 a[i] = v; |
66 a[key] = i; | 66 a[key] = i; |
67 return key; | 67 return key; |
68 end | 68 end |
69 | 69 |