Software /
code /
prosody-modules
Changeset
2803:9db18f909b84
mod_storage_memory: Allow archive items to be overwritten by id
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 18 Oct 2017 20:25:48 +0200 |
parents | 2802:0d5d1ff96600 |
children | 2804:b50f7b9fdbbb |
files | mod_storage_memory/mod_storage_memory.lua |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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;