aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_internal.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-10-08 18:21:14 +0200
committerKim Alvefur <zash@zash.se>2023-10-08 18:21:14 +0200
commit4d699626445b5a5b03435732b3cded4057b704c2 (patch)
tree2dd5d1c1ef468ddb44894d6b6321f186deadbb83 /plugins/mod_storage_internal.lua
parent069bcf619b5ce62f79f249a43432fa2de2281d1d (diff)
downloadprosody-4d699626445b5a5b03435732b3cded4057b704c2.tar.gz
prosody-4d699626445b5a5b03435732b3cded4057b704c2.zip
mod_storage_internal: Don't report error when attempting to trim empty archive
Fixes "Could not delete messages for room 'x': (nil)"
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r--plugins/mod_storage_internal.lua8
1 files changed, 7 insertions, 1 deletions
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);