Changeset

13263:e77994e88940

mod_storage_internal: Don't report error when attempting to trim empty archive Fixes "Could not delete messages for room 'x': (nil)"
author Kim Alvefur <zash@zash.se>
date Sun, 08 Oct 2023 18:21:14 +0200 (14 months ago)
parents 13262:9a86e7cbdd79
children 13264:9b720c38fee8
files plugins/mod_storage_internal.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);