Diff

mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 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
parent 3435:26a549513f02
child 3453:41e1cacf3c4e
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