Changeset

2040:459e1878d23c

mod_storage_xmlarchive: Return earlier if attempting to delete from empty archive
author Kim Alvefur <zash@zash.se>
date Tue, 02 Feb 2016 16:27:38 +0100
parents 2039:464edd03099a
children 2041:7c61ab512d0b
files mod_storage_xmlarchive/mod_storage_xmlarchive.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Tue Feb 02 16:26:21 2016 +0100
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Tue Feb 02 16:27:38 2016 +0100
@@ -182,7 +182,11 @@
 	end
 	local before = query.before or query["end"] or "9999-12-31";
 	if type(before) == "number" then before = dt.date(before); else before = before:sub(1, 10); end
-	local dates = dm.list_load(username, module.host, self.store) or empty;
+	local dates, err = dm.list_load(username, module.host, self.store);
+	if not dates or next(dates) == nil then
+		if not err then return true end -- already empty
+		return dates, err;
+	end
 	local remaining_dates = {};
 	for d = 1, #dates do
 		if dates[d] >= before then