Changeset

2357:093b70378fa5

mod_storage_muc_log: Separate out date collection into API method
author Kim Alvefur <zash@zash.se>
date Wed, 09 Nov 2016 13:38:44 +0100
parents 2356:49a01b78b45f
children 2358:f96b947303a2
files mod_storage_muc_log/mod_storage_muc_log.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_muc_log/mod_storage_muc_log.lua	Wed Nov 09 13:37:58 2016 +0100
+++ b/mod_storage_muc_log/mod_storage_muc_log.lua	Wed Nov 09 13:38:44 2016 +0100
@@ -67,7 +67,7 @@
 	return today .. "_" .. #data;
 end
 
-function driver:find(node, query)
+function driver:dates(node)
 	local path = datamanager.getpath(node, host, datastore):match("(.*)/");
 
 	local ok, iter, state, var = pcall(lfs.dir, path);
@@ -84,6 +84,12 @@
 	end
 	if dates[1] == nil then return noop, 0; end
 	table.sort(dates);
+	return dates;
+end
+
+function driver:find(node, query)
+	local dates, err = self:dates(node);
+	if not dates then return dates, err; end
 
 	return coroutine.wrap(function ()
 		local start_date = query and query.start and os_date(datef, query.start) or dates[1];