Software /
code /
prosody-modules
Diff
mod_storage_gdbm/mod_storage_gdbm.lua @ 1653:1fe899527ee5
mod_storage_gdbm: Cleanup [luacheck]
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 07 Apr 2015 17:35:37 +0200 |
parent | 1635:b877b75eb973 |
child | 1753:54c8a0cb2996 |
line wrap: on
line diff
--- a/mod_storage_gdbm/mod_storage_gdbm.lua Tue Apr 07 17:35:20 2015 +0200 +++ b/mod_storage_gdbm/mod_storage_gdbm.lua Tue Apr 07 17:35:37 2015 +0200 @@ -5,6 +5,8 @@ -- -- Depends on lgdbm: -- http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/#lgdbm +-- +-- luacheck: globals open purge local gdbm = require"gdbm"; local path = require"util.paths"; @@ -19,8 +21,6 @@ local g_set, g_get, g_del = gdbm.replace, gdbm.fetch, gdbm.delete; local g_first, g_next = gdbm.firstkey, gdbm.nextkey; -local t_remove = table.remove; - local empty = {}; local function id(v) return v; end @@ -94,7 +94,7 @@ return key; end -local deserialize = { +local deserialize_map = { stanza = st.deserialize; }; @@ -123,7 +123,7 @@ and (not query["end"] or item.when <= query["end"]) then s = i + d; c = c + 1; value = self:get(prefix..item.key); - return item.key, (deserialize[item.type] or id)(value), item.when, item.with; + return item.key, (deserialize_map[item.type] or id)(value), item.when, item.with; end end end @@ -164,7 +164,8 @@ end function module.unload() - for path, db in pairs(cache) do + for db_path, db in pairs(cache) do + module:log("debug", "Closing db at %q", db_path); gdbm.sync(db); gdbm.close(db); end