# HG changeset patch # User Kim Alvefur # Date 1428420937 -7200 # Node ID 1fe899527ee5c66ee474eb7379521ffd48874b32 # Parent 9a3d2f1479a48d6b3751dc5033ea19ad8025b149 mod_storage_gdbm: Cleanup [luacheck] diff -r 9a3d2f1479a4 -r 1fe899527ee5 mod_storage_gdbm/mod_storage_gdbm.lua --- 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