# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1427300994 -3600
# Node ID 5e4b37b9cde1b0467c31fc11c9a8403f726850e1
# Parent  458c80904525f3ea7422b2c94aab09933ce77ddf
mod_storage_gdbm: Fix traceback if query is nil or no metadata exists

diff -r 458c80904525 -r 5e4b37b9cde1 mod_storage_gdbm/mod_storage_gdbm.lua
--- 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)];