Mercurial > prosody-modules
changeset 3452:0c539092aa75
mod_storage_xmlarchive: Allow lookup of IDs that don't follow the YYYY-MM-DD-RANDOM format
E.g. for converted archives where the IDs are preserved. This will be
expensive.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 Jan 2019 19:17:49 +0100 (2019-01-21) |
parents | 7b97abf26612 |
children | 41e1cacf3c4e |
files | mod_storage_xmlarchive/mod_storage_xmlarchive.lua |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Sun Jan 20 18:18:02 2019 +0100 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Mon Jan 21 19:17:49 2019 +0100 @@ -59,9 +59,9 @@ function archive:_get_idx(username, id, dates) module:log("debug", "Looking for item with id %q", id); dates = dates or self:dates(username) or empty; - local date = id:sub(1, 10); + local date = id:match("^%d%d%d%d%-%d%d%-%d%d"); for d = 1, #dates do - if date == dates[d] then + if not date or date == dates[d] then module:log("debug", "Loading index for %s", dates[d]); local items = dm.list_load(username .. "@" .. dates[d], self.host, self.store) or empty; for i = 1, #items do @@ -70,7 +70,7 @@ end end return; -- Assuming no duplicates - elseif date < dates[d] then + elseif date and date < dates[d] then return; -- List is assumed to be sorted end end