mod_storage_internal: Don't report error when attempting to trim empty archive
authorKim Alvefur <zash@zash.se>
Sun, 08 Oct 2023 18:21:14 +0200
changeset 13267 e77994e88940
parent 13266 9a86e7cbdd79
child 13268 9b720c38fee8
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
--- 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);