# HG changeset patch # User Kim Alvefur # Date 1508351148 -7200 # Node ID 9db18f909b845719272b95f6f81efdc70ba4d7fe # Parent 0d5d1ff96600f682529d358c3a2ea9e6e89861c7 mod_storage_memory: Allow archive items to be overwritten by id diff -r 0d5d1ff96600 -r 9db18f909b84 mod_storage_memory/mod_storage_memory.lua --- a/mod_storage_memory/mod_storage_memory.lua Wed Oct 18 20:24:47 2017 +0200 +++ b/mod_storage_memory/mod_storage_memory.lua Wed Oct 18 20:25:48 2017 +0200 @@ -55,10 +55,13 @@ end local i = #a+1; local v = { key = key, when = when, with = with, value = value }; - if not key or a[key] then + if not key then key = tostring(a):match"%x+$"..tostring(v):match"%x+$"; v.key = key; end + if a[key] then + table.remove(a, a[key]); + end a[i] = v; a[key] = i; return key;