comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 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 a85b5c3791dc
children 7c61ab512d0b
comparison
equal deleted inserted replaced
2039:464edd03099a 2040:459e1878d23c
180 if query.with or query.start or query.after then 180 if query.with or query.start or query.after then
181 return nil, "not-implemented"; -- Only trimming the oldest messages 181 return nil, "not-implemented"; -- Only trimming the oldest messages
182 end 182 end
183 local before = query.before or query["end"] or "9999-12-31"; 183 local before = query.before or query["end"] or "9999-12-31";
184 if type(before) == "number" then before = dt.date(before); else before = before:sub(1, 10); end 184 if type(before) == "number" then before = dt.date(before); else before = before:sub(1, 10); end
185 local dates = dm.list_load(username, module.host, self.store) or empty; 185 local dates, err = dm.list_load(username, module.host, self.store);
186 if not dates or next(dates) == nil then
187 if not err then return true end -- already empty
188 return dates, err;
189 end
186 local remaining_dates = {}; 190 local remaining_dates = {};
187 for d = 1, #dates do 191 for d = 1, #dates do
188 if dates[d] >= before then 192 if dates[d] >= before then
189 table.insert(remaining_dates, dates[d]); 193 table.insert(remaining_dates, dates[d]);
190 end 194 end