From 534dae716450dbb1cfbdaa9abb407bec2e68b26b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 21 Oct 2018 18:00:46 +0200 Subject: mod_storage_memory: Fix overwriting old keys Test fixed is: spec/core_storagemanager_spec.lua:309: Expected objects to be equal. --- plugins/mod_storage_memory.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_storage_memory.lua') diff --git a/plugins/mod_storage_memory.lua b/plugins/mod_storage_memory.lua index 20135d86..cbbc5e29 100644 --- a/plugins/mod_storage_memory.lua +++ b/plugins/mod_storage_memory.lua @@ -53,7 +53,6 @@ function archive_store:append(username, key, value, when, with) a = {}; self.store[username or NULL] = a; end - local i = #a+1; local v = { key = key, when = when, with = with, value = value }; if not key then key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; @@ -62,6 +61,7 @@ function archive_store:append(username, key, value, when, with) if a[key] then table.remove(a, a[key]); end + local i = #a+1; a[i] = v; a[key] = i; return key; -- cgit v1.2.3