# HG changeset patch # User Kim Alvefur # Date 1689957006 -7200 # Node ID 9c72f93b7a02290d01352d30624ec554bf2c7aa7 # Parent dbd7a6b09ada722d1adef770041e4aace84ba212 util.datamanager: Add way to close indexed list store diff -r dbd7a6b09ada -r 9c72f93b7a02 util/datamanager.lua --- a/util/datamanager.lua Fri Jul 21 18:28:54 2023 +0200 +++ b/util/datamanager.lua Fri Jul 21 18:30:06 2023 +0200 @@ -461,6 +461,13 @@ return item; end +local function list_close(list) + if list.index and list.index.file then + list.index.file:close(); + end + return list.file:close(); +end + local indexed_list_mt = { __index = function(t, i) if type(i) ~= "number" or i % 1 ~= 0 or i < 1 then @@ -476,6 +483,7 @@ __len = function(t) return #t.index; end; + __close = list_close; } local function list_load(username, host, datastore) @@ -516,7 +524,7 @@ file:close() return index, err; end - return setmetatable({ file = file; index = index }, indexed_list_mt); + return setmetatable({ file = file; index = index; close = list_close }, indexed_list_mt); end local function shift_index(index_filename, index, trim_to, offset)