Diff

mod_storage_gdbm/mod_storage_gdbm.lua @ 1628:5e4b37b9cde1

mod_storage_gdbm: Fix traceback if query is nil or no metadata exists
author Kim Alvefur <zash@zash.se>
date Wed, 25 Mar 2015 17:29:54 +0100
parent 1604:53052a610c67
child 1629:36eb0dbea7ba
line wrap: on
line diff
--- a/mod_storage_gdbm/mod_storage_gdbm.lua	Tue Mar 24 08:03:25 2015 -0700
+++ b/mod_storage_gdbm/mod_storage_gdbm.lua	Wed Mar 25 17:29:54 2015 +0100
@@ -15,6 +15,8 @@
 local serialize = serialization.serialize;
 local deserialize = serialization.deserialize;
 
+local empty = {};
+
 local function id(v) return v; end
 
 local function is_stanza(s)
@@ -76,7 +78,8 @@
 };
 
 function archive:find(username, query)
-	local meta = self:get(username);
+	query = query or empty_query;
+	local meta = self:get(username) or empty;
 	local r = query.reverse;
 	local d = r and -1 or 1;
 	local s = meta[ifelse(r, query.before, query.after)];