aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-07-21 18:30:06 +0200
committerKim Alvefur <zash@zash.se>2023-07-21 18:30:06 +0200
commite6d0a3e6390ebfb0f39394a10fb12825bcf13b20 (patch)
treefd647b5e1f7f75d86359dcc3a424ef6855c425a9 /util
parentcd5b2664bedeff9f27fae042e086ffdb40890c5d (diff)
downloadprosody-e6d0a3e6390ebfb0f39394a10fb12825bcf13b20.tar.gz
prosody-e6d0a3e6390ebfb0f39394a10fb12825bcf13b20.zip
util.datamanager: Add way to close indexed list store
Diffstat (limited to 'util')
-rw-r--r--util/datamanager.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/util/datamanager.lua b/util/datamanager.lua
index 3a6a462f..2fc89a79 100644
--- a/util/datamanager.lua
+++ b/util/datamanager.lua
@@ -461,6 +461,13 @@ local function list_load_one(fh, start, length)
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 @@ local indexed_list_mt = {
__len = function(t)
return #t.index;
end;
+ __close = list_close;
}
local function list_load(username, host, datastore)
@@ -516,7 +524,7 @@ local function list_open(username, host, datastore)
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)