mod_storage_internal: Close lazy-loading list abstraction after trim
authorKim Alvefur <zash@zash.se>
Sun, 26 Nov 2023 14:35:26 +0100
changeset 13348 958c759d3897
parent 13347 9a9455de295d
child 13349 a74251a790ed
mod_storage_internal: Close lazy-loading list abstraction after trim Should be done here too.
plugins/mod_storage_internal.lua
--- a/plugins/mod_storage_internal.lua	Sun Nov 26 14:29:08 2023 +0100
+++ b/plugins/mod_storage_internal.lua	Sun Nov 26 14:35:26 2023 +0100
@@ -360,6 +360,9 @@
 	-- 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);
 	if last <= to_when then
+		if list.close then
+			list:close()
+		end
 		return datamanager.list_store(username, host, self.store, nil);
 	end
 
@@ -368,6 +371,9 @@
 		local when = item.when or datetime.parse(item.attr.stamp);
 		return to_when - when;
 	end);
+	if list.close then
+		list:close()
+	end
 	-- TODO if exact then ... off by one?
 	if i == 1 then return 0; end
 	local ok, err = datamanager.list_shift(username, host, self.store, i);