mod_storage_internal: Don't report error when attempting to trim empty archive
Fixes "Could not delete messages for room 'x': (nil)"
--- a/plugins/mod_storage_internal.lua Sun Sep 24 13:41:54 2023 +0200
+++ b/plugins/mod_storage_internal.lua Sun Oct 08 18:21:14 2023 +0200
@@ -346,7 +346,13 @@
function archive:trim(username, to_when)
local list, err = datamanager.list_open(username, host, self.store);
- if not list then return list,err;end
+ if not list then
+ if err == nil then
+ module:log("debug", "store already empty, can't trim");
+ return 0;
+ end
+ return list, err;
+ end
-- shortcut: check if the last item should be trimmed, if so, drop the whole archive
local last = list[#list].when or datetime.parse(list[#list].attr.stamp);