# HG changeset patch # User Kim Alvefur # Date 1490091437 -3600 # Node ID 1330ed88ecd89a0624eea70c7ddbe1179a97bd65 # Parent 995d4d9f5d89b18dd711d1ab4aaa2499a7d7e6fc mod_storage_xmlarchive: Cache current date in a local diff -r 995d4d9f5d89 -r 1330ed88ecd8 mod_storage_xmlarchive/mod_storage_xmlarchive.lua --- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Tue Mar 21 10:56:56 2017 +0100 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Tue Mar 21 11:17:17 2017 +0100 @@ -177,10 +177,11 @@ return function () if limit and count >= limit then if xmlfile then xmlfile:close() end return; end for d = start_day, last_day, step do + local date = dates[d]; if not items then - module:log("debug", "Loading items from %s", dates[d]); + module:log("debug", "Loading items from %s", date); start_day = d; - items = dm.list_load(username .. "@" .. dates[d], module.host, self.store) or empty; + items = dm.list_load(username .. "@" .. date, module.host, self.store) or empty; if not rev then first_item, last_item = 1, #items; else @@ -192,7 +193,7 @@ for i = first_item, last_item, step do local item = items[i]; if not item then - module:log("warn", "data[%q][%d] is nil", dates[d], i); + module:log("warn", "data[%q][%d] is nil", date, i); break; end local i_when, i_with = item.when, item.with; @@ -200,7 +201,7 @@ i_when = dt.parse(i_when); end if type(i_when) ~= "number" then - module:log("warn", "data[%q][%d].when is invalid", dates[d], i); + module:log("warn", "data[%q][%d].when is invalid", date, i); break; end if (not q_with or i_with == q_with) @@ -209,7 +210,7 @@ count = count + 1; first_item = i + step; - local data = read_xml(dates[d], item.offset, item.length); + local data = read_xml(date, item.offset, item.length); if not data then return end local ok, err = stream:feed(data); if not ok then