From 4d699626445b5a5b03435732b3cded4057b704c2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 Oct 2023 18:21:14 +0200 Subject: mod_storage_internal: Don't report error when attempting to trim empty archive Fixes "Could not delete messages for room 'x': (nil)" --- plugins/mod_storage_internal.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua index bde294b2..da562201 100644 --- a/plugins/mod_storage_internal.lua +++ b/plugins/mod_storage_internal.lua @@ -346,7 +346,13 @@ end 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); -- cgit v1.2.3