comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 4647:b91e40472d68

mod_storage_xmlarchive: Fix return of numeric 'when' from key-value API At some point, 'when' was stored as a timestamp string then as a numeric UNIX timestamp, so both cases needs to be handled, as they are elsewhere. Thanks spec/core_storagemanager_spec.lua
author Kim Alvefur <zash@zash.se>
date Fri, 13 Aug 2021 01:37:15 +0200
parents 072d078be095
children 37ca6109077f
comparison
equal deleted inserted replaced
4646:072d078be095 4647:b91e40472d68
1 -- mod_storage_xmlarchive 1 -- mod_storage_xmlarchive
2 -- Copyright (C) 2015-2020 Kim Alvefur 2 -- Copyright (C) 2015-2021 Kim Alvefur
3 -- 3 --
4 -- This file is MIT/X11 licensed. 4 -- This file is MIT/X11 licensed.
5 -- 5 --
6 -- luacheck: ignore unused self 6 -- luacheck: ignore unused self
7 7
82 local p,err = xmlfile:seek("set", item.offset); 82 local p,err = xmlfile:seek("set", item.offset);
83 if p ~= item.offset or err ~= nil then return nil, err; end 83 if p ~= item.offset or err ~= nil then return nil, err; end
84 local data = xmlfile:read(item.length); 84 local data = xmlfile:read(item.length);
85 local parsed, perr = xml.parse(data); 85 local parsed, perr = xml.parse(data);
86 if not parsed then return nil, perr; end 86 if not parsed then return nil, perr; end
87 return parsed, dt.parse(item.when), item.with; 87 return parsed, tonumber(item.when) or dt.parse(item.when), item.with;
88 end 88 end
89 89
90 local overwrite = module:get_option("xmlarchive_overwrite", false); 90 local overwrite = module:get_option("xmlarchive_overwrite", false);
91 91
92 function archive:set(username, id, data, new_when, new_with) 92 function archive:set(username, id, data, new_when, new_with)