Comparison

plugins/mod_storage_internal.lua @ 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
parent 13262:9a86e7cbdd79
comparison
equal deleted inserted replaced
13262:9a86e7cbdd79 13263:e77994e88940
344 return datamanager.users(host, self.store, "list"); 344 return datamanager.users(host, self.store, "list");
345 end 345 end
346 346
347 function archive:trim(username, to_when) 347 function archive:trim(username, to_when)
348 local list, err = datamanager.list_open(username, host, self.store); 348 local list, err = datamanager.list_open(username, host, self.store);
349 if not list then return list,err;end 349 if not list then
350 if err == nil then
351 module:log("debug", "store already empty, can't trim");
352 return 0;
353 end
354 return list, err;
355 end
350 356
351 -- shortcut: check if the last item should be trimmed, if so, drop the whole archive 357 -- shortcut: check if the last item should be trimmed, if so, drop the whole archive
352 local last = list[#list].when or datetime.parse(list[#list].attr.stamp); 358 local last = list[#list].when or datetime.parse(list[#list].attr.stamp);
353 if last <= to_when then 359 if last <= to_when then
354 return datamanager.list_store(username, host, self.store, nil); 360 return datamanager.list_store(username, host, self.store, nil);